0

I need to format a string and send it to a web browser with the splinter module. I usually use placeholder, but this time it doesn't work. This is the string I want to pass to the browser:

http://NAMESERVER:8082/ViewObjectRes//TransactionLogManagerPostErrorHandling\%28Instance+0\%29\%3Ainstance\%3DInstance+0

where NAMESERVER is the fqdn of the server which I want to connect to. I tried use the placeholder as usual but I get an error:

print ("http://%s:8082/ViewObjectRes//TransactionLogManagerPostErrorHandling\\%28Instance+0\\%29\\%3Ainstance\\%3DInstance+0" % "TEST")

TypeError: not enough arguments for format string

I guess should escape all the other percentage sign, but I tried without success.

2
  • Your guess is correct. Can you show us your try? Commented Sep 15, 2014 at 10:15
  • After your confirmation, I was able to search better and find the solution. I used double percentage sign %%. thank you very much! Commented Sep 15, 2014 at 10:27

1 Answer 1

1

possibly easier, with a url that might contain %, to use format?

print "http://{}:8082/ViewObjectRes//TransactionLogManagerPostErrorHandling\\%28Instance+0\\%29\\%3Ainstance\\%3DInstance+0".format("TEST")
Sign up to request clarification or add additional context in comments.

1 Comment

I had complitely neglected to study the format function... it looks more elegant than placeholder for my purpose. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.