【发布时间】:2015-10-03 06:01:18
【问题描述】:
我们可以这样做来输入任何参数:
from sys import argv
script, argument_1, argument_2 = argv
是否可以在代码中间而不是开头输入参数?
我也想这样做:
print "La-la-la"
print "Any string"
# and here i want the program will take a file name as an argument to work with the file then
【问题讨论】:
-
这个问题完全无法解读。我不知道你想完成什么。
-
您可以随时查看 sys.argv。
-
刺入黑暗:你的意思是
input()? -
deceze,也许吧。它在 Python 2.7.10 中有效吗?
-
在左上角的手册页上有一个选择器,可让您选择另一个 Python 版本...自己看看。