执行脚本时传入参数: tmp.py import sys for i in sys.argv: print(i) 在cmd下执行:python tmp.py -c -d test 输出内容为: tmp.py -c -d tmp <完>