python 3 argparse的使用记录

在项目中会用到argparse这个模块,相关demo代码如下:

parser = argparse.ArgumentParser(description='File compare and upload ftp server')

parser.add_argument('-path', metavar='path', required=True,
dest='path', nargs='+',
help='File path to compress')

parser.add_argument('-upload', dest='upload', required=True,
action='store',
help='Uploaded ftp server directory')

parser.add_argument('-v', dest='verbose', action='store_true',
help='verbose mode')

args = parser.parse_args()


posted @ 2020-04-08 11:58  进击的pythoner  阅读(214)  评论(0编辑  收藏  举报