已采纳回答 / 慕村1348781
问题还是我自己通查多方资料解决了,案例中不管是pdf文件还是doc文件,都是打开word软件转格式,所以最关键的就是一个能打开pdf格式的word版本,我使用word2016可行。代码也没问题。如果运行后txt显示乱码,建议更换office版本到2016。
2019-09-15
转PDF提示
AttributeError: 'NoneType' object has no attribute 'SaveAs'
AttributeError: 'NoneType' object has no attribute 'SaveAs'
2019-08-07
pdf转txt失败
mytxt = pdfapp.Documents.Open(filePath)
File "<COMObject <unknown>>", line 8, in Open
pywintypes.com_error: (-2147352567, '发生意外。', (0, 'Microsoft Word', '文件可能已经损坏。', 'wdmain11.chm', 25272, -2146822496), None)
mytxt = pdfapp.Documents.Open(filePath)
File "<COMObject <unknown>>", line 8, in Open
pywintypes.com_error: (-2147352567, '发生意外。', (0, 'Microsoft Word', '文件可能已经损坏。', 'wdmain11.chm', 25272, -2146822496), None)
2019-08-06
File "G:/python文件/转txt.py", line 42, in 转txt
mytxt = wordapp.Documents.Open(filePath)
File "<COMObject <unknown>>", line 8, in Open
win32.types.com_error: (-2147352567, '发生意外。', (0, 'Kingsoft WPS', '文档打开失败。', '', 3010, -786427), None)
mytxt = wordapp.Documents.Open(filePath)
File "<COMObject <unknown>>", line 8, in Open
win32.types.com_error: (-2147352567, '发生意外。', (0, 'Kingsoft WPS', '文档打开失败。', '', 3010, -786427), None)
2019-08-01