zoukankan      html  css  js  c++  java
  • 为python脚本增加命令行参数

    from argparse import ArgumentParser
    
    p = ArgumentParser()
    p.add_argument('-b', '--body', help='Return USN records in comma-separated format', action='store_true')
    p.add_argument('-c', '--csv', help='Return USN records in comma-separated format', action='store_true')
    p.add_argument('-f', '--file', help='Parse the given USN journal file', required=True)
    p.add_argument('-o', '--outfile', help='Parse the given USN journal file', required=True)
    p.add_argument('-s', '--system', help='System name (use with -t)')
    p.add_argument('-t', '--tln', help='TLN ou2tput (use with -s)', action='store_true')
    p.add_argument('-v', '--verbose', help='Return all USN properties for each record (JSON)', action='store_true')
    args = p.parse_args()
    
    
    journalSize = os.path.getsize(args.file)
    with open(args.file, 'rb') as i:
    	with open(args.outfile, 'wb') as o:
    		i.seek(findFirstRecord(i))
    		if args.csv:
    		    do something
    

    使用标准库的参数分析模块, 以属性的方式, 拿到具体的参数.

  • 相关阅读:
    stl_heap
    关于随机数 C++
    关于if语句的细节
    C++关于智能指针
    sqlyog
    win10 64位 汇编环境
    Qt 乱码
    Vux使用经验
    Flex布局新旧混合写法详解
    【原】npm 常用命令详解
  • 原文地址:https://www.cnblogs.com/crb912/p/10384865.html
Copyright © 2011-2022 走看看