运维开发网
广告位招商联系QQ:123077622
 
广告位招商联系QQ:123077622

Python的sys.argv用法

运维开发网 https://www.qedev.com 2020-07-21 11:55 出处:网络 作者:运维开发网整理
import sys a = sys.argv[:] print(\"输入的参数为:\", a) def train_start(start_time, end_time, select_equipment):
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

Python的sys.argv用法

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消