今日主要是學(xué)習(xí)了標(biāo)準(zhǔn)庫(kù)中的argparse模塊
做什么用?
命令行解析工具
參考文章 :
http://lingxiankong.github.io/blog/2014/01/14/command-line-parser/
https://docs.python.org/3.6/howto/argparse.html
最后看了下flask_scripts 中的 manger.add_command 源碼中實(shí)際調(diào)用的就是args.add_argument()函數(shù)
ps:需要區(qū)別的幾個(gè)東西
位置參數(shù)
parser.add_argument("square", help="display a square of a given number", type=int)
可選參數(shù)(后面必須有value)
parser.add_argument("--cubic", help="display a cubic of a given number", type=int)