import fnmatchimport osimport sys import win32com.client readpath=r'D:\123' wordapp = win32com.client.gencache.EnsureDispatch("Word.Application") try: for path, dirs, files in os.walk(readpath): for filename in files: if not fnmatch.fnmatch(filename, '*.docx'):continue doc = os.path.abspath(os.path.join(path,filename)) print 'processing %s...' % doc wordapp.Documents.Open(doc) docastext = doc[:-4] + 'txt' wordapp.ActiveDocument.SaveAs(docastext,FileFormat=win32com.client.constants.wdFormatText) wordapp.ActiveDocument.Close() finally: wordapp.Quit() print 'end' f=open(r'd:\123\test.txt','r') for line in f.readlines(): print line.decode('gbk') f.close()SyntaxError: multiple statements found while compiling a single statement
添加回答
举报
0/150
提交
取消