Python的sys.argv用法
import sys
a = sys.argv[:]
print("输入的参数为:", a)
def train_start(start_time, end_time, select_equipment):
print('start_time = ', start_time)
print("end_time = ", end_time)
print('select_time = ', select_equipment)
ids = select_equipment.split(',')
print("ids = ", ids)
if __name__ == "__main__":
for i, argv in enumerate(sys.argv[:]):
print("i = ", i, '; argv = ', argv)
print("=========================")
if len(sys.argv) == 5 and sys.argv[4] == '0':
start_time = sys.argv[1]
end_time = sys.argv[2]
select_equipment = sys.argv[3]
train_start(start_time, end_time, select_equipment)
# 命令行输入:python test.py 2019-08-05 2019-09-01 1,5 0
本文版权归作者和博客园共有,欢迎转载,转载请注明出处和链接来源。