Python 为什么docopt在解析参数后退出脚本?

Python 为什么docopt在解析参数后退出脚本?,python,docopt,Python,Docopt,我使用docopt已经有一段时间了,在一个新脚本上,我无法通过参数解析: # coding=utf-8 """ API server for the infoscreen frontends Usage: python3 webserver.py [options] Options: --bind ADDRESS address to bind to [default: 0.0.0.0] --galarmclock URL URL for the galarmc

我使用
docopt
已经有一段时间了,在一个新脚本上,我无法通过参数解析:

# coding=utf-8
"""
API server for the infoscreen frontends

Usage:
    python3 webserver.py [options]

Options:
    --bind ADDRESS  address to bind to  [default: 0.0.0.0]
    --galarmclock URL  URL for the galarmclock API [default: http://10.100.10.202:8082]
    --loglevel LOG  logging level   [default: logging.DEBUG]
    --console   log to console [default: False]
    --syslog    log to syslog [default: False]

"""

import docopt

# process arguments
args = docopt.docopt(__doc__)
print(args)
所有参数(参数)都是可选的,并且都有默认值,那么为什么脚本会停止

C:\Python3\python.exe C:/tst.py
Usage:
    python3 webserver.py [options]

Process finished with exit code 1

问题在于使用部分:

Usage:
    python3 webserver.py [options]
Docopt希望使用部分中的第一个字符串是您的程序,而不是python。因此docopt将其解释为
python3
是您的程序,并且它总是使用名为
webserver.py
的命令。如果删除
python3
部分,它应该可以像这样工作:

Usage:
    webserver.py [options]
我们从以下方面:

出现在关键字用法:(不区分大小写)和可见空行之间的文本被解释为用法模式列表。用法:后的第一个单词被解释为程序名