import sys
print("the number of arguments is %d" % len(sys.argv))
print(sys.argv)
for i in range(len(sys.argv)):
print("%d:" % i + sys.argv[i])
執行:
$ python testarg.py a b c the number of arguments is 4 ['testarg.py', 'a', 'b', 'c'] 0:testarg.py 1:a 2:b 3:c
沒有留言:
張貼留言