gpt4 book ai didi

python - TypeError : must be dict, 不是 str

转载 作者:太空宇宙 更新时间:2023-11-04 10:55:20 25 4
gpt4 key购买 nike

嘿伙计们,我试图在 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()不接受命令参数。尝试使用 subprocess相反。

关于python - TypeError : must be dict, 不是 str,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10261551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com