📜  将参数传递给 py 文件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:23.248000             🧑  作者: Mango

代码示例1
import sys

def hello(a,b):
    print "hello and that's your sum:", a + b

if __name__ == "__main__":
    a = int(sys.argv[1])
    b = int(sys.argv[2])
    hello(a, b)
# If you type : py main.py 1 5
# It should give you "hello and that's your sum:6"