【发布时间】:2014-12-05 18:46:34
【问题描述】:
我是 python 的新手,正在尝试编写一个 python 脚本,它需要两个命令行参数,对它们做一些事情,然后将输出返回到标准输出。
我的脚本是这样的:
class MyClass:
def GET(self):
#get the passed in arguments in arg1 and arg2
return self.perform(arg1, arg2)
def perform(self, arg1, arg2):
return arg1+arg2
if __name__ == "__main__":
#call the GET method of MyClass with all the arguments
- 如何将命令行参数
sys.argv[1:]传递给MyClass的GET方法? -
GET的签名会从GET(self)变成GET(self, arg1, arg2)吗?
【问题讨论】:
-
看来你已经有了答案!
标签: python command-line command-line-arguments