一个改进“文件/命令未找到”错误消息的模块,带有“您的意思是”建议。
PyDidYouMean的Python项目详细描述
你的意思是
一个改进“文件/命令未找到”错误消息的模块,带有“您的意思是”建议。
安装时使用:
pip install pydidyoumean
典型用法:
if FILE_NOT_FOUND:
pydidyoumean.printFileSuggestion(FILENAME) # if no suggested file is found in the cwd, this prints nothing
# prints out "Did you mean %s?\n" % (SUGGESTED_FILENAME)
if COMMAND_NOT_FOUND:
pydidyoumean.printSuggestion(CMD_NAME, LIST_OF_ALL_CMDS) # if no suggested command is found, this prints nothing
# prints out "Did you mean %s?\n" % (SUGGESTED_CMD)
还有一些其他函数和可选参数用于自定义消息或获取建议。文档位于https://pydidyoumean.readthedocs.org