【发布时间】:2011-12-03 22:16:51
【问题描述】:
有一个关于在 Python 中运行脚本的快速问题。我在保存为“ex13.py”的文件中输入了以下代码:
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
当我尝试从 IDLE 的下拉菜单中简单地“运行”它时,它给了我这个错误:
Traceback (most recent call last):
File "/Users/brianerke 2/Desktop/ex13.py", line 3, in <module>
script, first, second, third = argv
ValueError: need more than 1 value to unpack
我需要在解释器/终端中输入什么来运行这个脚本?非常感谢!
布赖恩
【问题讨论】:
-
请参阅this question,了解有关将命令行参数传递给要在 IDLE 中运行的脚本的信息。
-
那里描述的方法在 Python 的标准 OS X 安装上不太适用,因为 IDLE 不是以这种方式安装的,即它只是作为
idle安装的。但 IDLE 通常在 OS X 上通过双击图标来启动。
标签: python macos python-idle