命令行工具

1.click模块

  click模块和argparse功能相同,但更为易用,使用click分为两个步骤,1)使用@click.command()装饰一个函数,使之成为命令行接口;2)使用@click.option()等装饰函数,为其添加命令行选项等

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 hellp(count,name):
    '''simple program thar greets NAME for total of COUNT times...'''
    for x in range(count):
        click.echo('Hello %s!!!' % name)
if __name__ == '__main__':
    hellp()
click实例

相关文章:

  • 2021-09-23
  • 2021-08-18
  • 2021-12-15
  • 2021-07-13
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-29
  • 2018-06-10
  • 2021-06-09
  • 2021-03-31
  • 2021-08-29
  • 2021-11-11
相关资源
相似解决方案