1. The first page describes the contents of the Word table as follows: Every two tables is followed by a merged cell
2. Introduction of the Win32com module
3. Specific code
1 #http://www.jb51.net/article/70318.htm2 #http://www.cnblogs.com/graphics/articles/2953665.html3 #http://shouce.jb51.net/python/4 ImportWin32com,re5 fromWin32com.clientImportdispatch,constants6 7 8Word=win32com.client.dispatch ('Word.Application')9 " "Ten set Word visibility visible, by default, you don't see the Word program, and then you set the warning message for Word to appear, and the default is not to appear, so you don't pop up word's warning when you use Python to control word. One " " Aword.displayalerts=0 -word.visible=0 -Countdoc=Word. Documents.count the Print(Countdoc) -Doc=word. Documents.Open (R'C:\Users\Administrator\Desktop\test\ Document One \1.doc') - #Doc. SaveAs (R ' C:\Users\Administrator\Desktop\test\ document One \1.txt ') - " " + T=doc. Tables[0] - #print (Type (t)) + tt=str (t) A #print (Type (TT)) at #print ("") - #分割字符串 - strs=tt.split (") - print (strs[5]) - " " -I=0 in whilei<500: -t=Doc. Tables[i] tott=str (t) +Strs=tt.split ('') - Print(strs[5]) theI=i+1 * $ Doc. Close ()Panax NotoginsengWord. Quit ()
Pythonword1
4. The problems encountered
1). Open Word always prompts for errors. Because My Documents and open initials are lowercase.
2).
I'm just going to get the table object into a string to handle.
Python reads Word table contents (1)