【发布时间】:2016-05-16 02:01:11
【问题描述】:
我正在尝试通过 Linux 终端打开我拥有的 python 脚本,格式如下所示:
$ python file_name.py a,b,c
在这里,a、b、c 是我在为程序编写的代码中使用的变量。目前我通过要求用户使用命令输入输入来获取输入 var_name = input("输入输入:")
但是,我想在打开文件本身时传递这三个变量的值,如上述格式中所述。 我是否必须利用课程来做到这一点?
我写的代码是:
print"Hello!"
circle = []
n = input("Enter the number of elements in the circle 'N' :")
for i in range(0,n):
circle.append(i)
print "The circle being formed is : " + str(circle)
m = input("Enter the value of M : ")
k = input("Enter the value of K : ")
index = m-1
while (len(circle)>k) :
del circle[index]
index = index + (m-1)
n = n - 1
index = (index)%n
print str(circle)
【问题讨论】:
标签: python class arguments command-line-arguments variable-declaration