Python specifies the operating environment through the CMD command

command description

"""
Usage:
  user_manage [<env>]
  user_manage  -h  |  --help
  user_manage  -v  |  --version

Options:
  -h --help        显示帮助菜单
  -v --version     查看版本号
  env               指定启动环境[default: dev]

"""


from docopt import docopt

if __name__ == '__main__':
    # 设置环境变量,读取不同环境的配置信息
    _env = 'dev'
    # _env = 'product'

    arguments=docopt(__doc__,version = 'Autoapi Testing')
    if arguments['<env>'] is not None:
        _env = arguments['<env>']
    log.info(f'当前启动环境是:{
      
      _env}')

Run the command:
the middle is the path of the current file

python docopt_l/docopt_ll.py env=po

Guess you like

Origin blog.csdn.net/qq_38122800/article/details/129196323