我正在使用docopt模块来处理python脚本选项:

from docopt import docopt
"""Usage:
  ./convert [ -h | -i | -t | -c ]

Options:
  -h          Show this help
  -i          Convert image to vertical scroll box
  -t          Convert text to vertical scroll box
  -c          Convert command list to html
"""

def main(docopt_args):
...
if __name__ == '__main__':
    args = docopt(__doc__, version='v0.1')
    main(args)

有什么提示吗?

最佳答案

将文档字符串移动到文件的开头(在导入行之前)

关于python docopt : "expected string or buffer",我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44867391/

10-12 13:58