【发布时间】:2012-04-21 17:59:56
【问题描述】:
大家好,我尝试在 Python 中使用参数变量,但无法在终端执行程序。
计划:
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
输出:
>>> execfile("lesson13.py","dog","cat")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: must be dict, not str
>>>
【问题讨论】:
-
错误与程序无关,你只是误用了
execfile。
标签: python