![]() |
String formatting with tuples
I'm having trouble printing out tuples.
Say, I have a function "joker": :
def joker(*args)::
joker("dad", "dasdsad", "dasdas"):
ERROR: not all arguments converted during string formatting:
print argsCan get this to work. Can you guys help? Thanks in advance. p/s: I'm also wondering what does the red part do? :
command="dasdasd" |
String formatting in Python either uses a single variable:
:
"Hello %s" % "World" => "Hello World":
"Name: %s, age: %d" % ("Frank", 27) => "Name: Frank, age: 27"The print command uses the repr function to show a human-readable representation of the data structure. So this: :
print (1, 2):
print "%s" % repr((1, 2)):
tup = ("Hello", "World"):
tup = ("Hello", 1):
tup = ("Hello", 1):
tup = ("Hello", 1) |
How about something like this:
:
def joker(*args): |
| All times are GMT -5. The time now is 12:45 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC