pypandoc giving the error “RuntimeError: source_file is not a valid path

pypandoc giving the error “RuntimeError: source_file is not a valid path

我的代码:

错误:

$ C:/Users/abc/AppData/Local/Programs/Python/Python38-32/python.exe e:/PYTHON/pdf_word_converter.py Traceback (most recent call last):
File "e:/PYTHON/pdf_word_converter.py", line 4, in conout = pypandoc.convert_file("E:\PYTHON67_Docusign.pdf", "docx", outputfile= "readme.docx") File "C:\Users\abc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pypandoc__init__.py", line 137, in convert_file raise RuntimeError("source_file is not a valid path") RuntimeError: source_file is not a valid path

是因为转义序列。

两种选择。

  • "E:\PYTHON67_Docusign.pdf"

  • 中的所有\替换为\
  • 使用原始字符串r"E:\PYTHON67_Docusign.pdf"