Symbian app on Python note usage
Question
When I try to use this command
appuifw.note(u"Connecting to %s" % (address), "conf");
I'm getting error: "not all arguments converted during string formatting"
How to fix this error?
Solution
The error you mentioned arise in cases like
>>> print "my name is %s" %('foo','bar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting
It means I have 2 values to replace ('foo', 'bar')
but only provided one
place holder (%s)
.
To correct it
>>> print "my name is %s %s" %('foo','bar')
my name is foo bar
There is also a another way to achieve this using str.format().
>>> print "my name is {0} {1}".format('foo','bar')
my name is foo bar
OTHER TIPS
There is another option with dictionaries
mydict = {'foo': 'bar', 'foo2': 'bar2'}
print "my name is %(foo)s" % mydict
this way you can use only foo if you want.
Note the last 's' is for 'string', so if you add something like %(foo)d it means %d with name foo.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow