I have such code in Python:
def send_start(self, player):
for p in self.players:
player[\"socket\"].send_cmd(\'
-
Your code would fail if self.turnnow
is an empty tuple:
>>> var = ()
>>> print "%s" % (var)
Traceback (most recent call last):
File "", line 2, in
TypeError: not enough arguments for format string
>>> print "%s" % (var,)
()
This is because a parenthesized expression in Python does not automatically become a tuple if the tuple would have only one element. (expr)
is equivalent to expr
. (expr, )
is equivalent to a one-element tuple holding expr
as the first element. So, try adding a comma after self.turnnow
in the second print
statement.
- 热议问题