Python Bulk Modify File script

Source: Internet
Author: User
Tags python script

Recently prepared to knock the "Thinginginjava" (people are more stupid, can only use this simple and rough method, haha)

You have to import the Net.mindview package

Import process Reference this blog: http://blog.sina.com.cn/s/blog_631a75580100vcig.html

In the middle of all the files in the Com.mindview to delete

Wrote a primitive Python script that was deleted in bulk

Since this is the first time to write scripts for your own convenience (which may also be the meaning of the script), remember

Here's the code:

Import Reimport osdef hand1 (curdir): for file_name in Os.listdir (curdir):p rint file_nameif (file_name!= ' hand.py '): Hand2 (file_name) def hand2 (file_name): fp = open (file_name, ' R ') Alllines=fp.readlines () Fp.closefp=open (file_name, ' W ') for Eachline in Alllines:a=re.sub (' Net.mindview. ', ' ", Eachline) Fp.writelines (a) fp.closeif __name__==" __main__ ": Hand1 ( Os.path.abspath ('. '))

  

Python Bulk Modify File script

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.