click:
官方主页:http://click.pocoo.org/5/
支持:
1 命令的任意嵌套 2 自动生成帮助信息 3 支持在运行时子命令的延迟加载
安装:
pip install click
例子:
import click @click.command() @click.option(‘--count‘, default=1, help=‘Number of greetings.‘) @click.option(‘--name‘, prompt=‘Your name‘, help=‘The person to greet.‘) def hello(count, name): """Simple program that greets NAME for a total of COUNT times.""" for x in range(count): click.echo(‘Hello %s!‘ % name) if __name__ == ‘__main__‘: hello()
运行:
$ python hello.py --help Usage: hello.py [OPTIONS] Simple program that greets NAME for a total of COUNT times. Options: --count INTEGER Number of greetings. --name TEXT The person to greet. --help Show this message and exit.
参考:
http://www.thinksaas.cn/topics/0/346/346148.html
时间: 2024-10-07 22:06:57