Python Changes the text

Source: Internet
Author: User

1 ImportOs#import file Operation module2 ImportRe#Import the regular module3 ImportWin32com#Import the Word action module4 5 #ready to open Word6  fromWin32com.clientImportdispatch,constants7W = Win32com.client.Dispatch ('Word.Application')8W.visible =09W.displayalerts =0Ten  One #get the full path of the text A #.. \1_ a unit \1_ "Yi reading" \1_ preview \1_ Sound and picture text -  forRoot, Dirnames, filenamesinchOs.walk (R'C:\Users\jack\Desktop\test\3_ Chinese language edition seven-year book'): - ##字符串前面加r之后, the \d in the regular does not change, ' \ ' becomes ' \ \ ', the beginning is ' ^$ ', match all is '. ' the ## if Re.match (R '. *\\\d+_\w+\\\d+_.+\\1_ Preview \\1_ Sound Draw text $ ', Dirpath): - ## Print (Dirpath) - ## Else: - ## print (' not found ') +          forFileNameinchFilenames: -                 ifRe.match (R'text. rtf', filename): +Classrtf =Os.path.join (root,filename) Adoc = W.documents.open (FileName =classrtf) at W.activedocument.select () - w.selection.clearformatting () -                         Print("processed:"+classrtf) - Doc. Close () - W.quit - Print("Finish the deal! ")

Python Changes the text

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.