在艰苦学习python练习13中,我们第一次导入了argv
。代码如下:
from sys import argv
script, first, second, third = argv
print 'The script is called:' script
print 'Your first variable is:' first
print 'Your second variable is:' second
print 'Your third variable is:' third
我得到的结果是:
donny@donny:~/Documents/pygame-scripts$ python ex13.py first second third
Traceback (most recent call last):
File "ex13.py", line 1, in <module>
d
NameError: name 'd' is not defined
我想不通。我在谷歌上搜索了一下,确认我完全复制了代码。任何帮助都将不胜感激。你知道吗
问题是
print
的参数之间缺少逗号。你知道吗请尝试以下操作:
编辑:
要使代码与python3兼容,请使用
print(arg1, arg2)
而不是print arg1, arg2
。你知道吗字符串后需要
,
。如下所示相关问题 更多 >
编程相关推荐