这个问题可能是因为文件路径中含有非ASCII字符而导致的。解决方法是使用Unicode编码,并在文件路径前添加'u”前缀,示例如下:
import os import subprocess import sys
filepath = u"C:\路径\info.doc" if os.path.exists(filepath): try: output = subprocess.check_output(["Antiword", filepath]) print(output.decode('utf-8')) except: print("Error: Unable to open file for reading.") else: print("Error: File not found.")
下一篇:antix更换debian源