码迷,mamicode.com
首页 > 编程语言 > 详细

Python的sys.argv用法

时间:2019-10-22 10:26:33      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:图片   pre   pytho   inf   mamicode   输入   info   img   end   

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用法

标签:图片   pre   pytho   inf   mamicode   输入   info   img   end   

原文地址:https://www.cnblogs.com/HongjianChen/p/11718119.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!