当我将以下内容作为Notepad++代码输入到Python中时:
days = "Mon"
print "Here are the days: %s ". % days 我在中获得了这个输出:
File "ex9exp.py", line 4
print "Here are the days: %s ". % days 我不知道为什么会发生这种事。
我打算把.
print "Here are the days: %s ". % days 成为
Here are the days: Mon 会很感激你的帮助。
发布于 2015-01-04 15:42:53
问题是您正在使用的print函数的语法是错误的。
>>> days = "Mon"
>>>
>>> print "Here are the days: %s ". % days
File "<stdin>", line 1
print "Here are the days: %s ". % days
^
SyntaxError: invalid syntax删除.。并尝试
>>> print "Here are the days: %s " % days
Here are the days: Mon 发布于 2015-02-25 01:13:43
还可以使用+追加字符串。
print "Here are the days: " + days行得通
https://stackoverflow.com/questions/27767152
复制相似问题