Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

请问下python test.py -h -s -f像这种方式是如何传参的呢

1.请问下python test.py -h 127.0.0.1 -port 3306像这种方式是如何编写脚本实现这种方式传参的呢 ,而不是python test.py 127.0.0.1 3306

2.我想写一个test.py --help的帮助文档是怎么写的呢,主要是对-h 和 -port这两个参数做解释### 问题描述


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

你需要的是命令行解析库,python标准库 argparse模块包含了用于创建命令行参数和选项程序的工具,它在 Python 2.7 中就已经加入。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...