0
我使用decopt模塊來處理python腳本選項:蟒蛇decopt: 「預期的字符串或緩衝區」
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)
Traceback (most recent call last):
File "/home/ajn/Converter-yaml-to-html-blocks/convert.py", line 66, in <module>
args = docopt(__doc__, version='v0.1')
File "/usr/local/lib/python3.4/dist-packages/docopt.py", line 558, in docopt
DocoptExit.usage = printable_usage(doc)
File "/usr/local/lib/python3.4/dist-packages/docopt.py", line 466, in printable_usage
usage_split = re.split(r'([Uu][Ss][Aa][Gg][Ee]:)', doc)
File "/usr/lib/python3.4/re.py", line 196, in split
return _compile(pattern, flags).split(string, maxsplit)
TypeError: expected string or buffer
任何提示?
我懷疑'__doc__'你傳遞是'None',既不是一個字符串或緩衝區。 (記住:「顯式比隱式更好」)。 – 9000