python-01, automatically write files

Source: Internet
Author: User

There is a list of attendance staff, each time to increase the deletion of staff too troublesome, find python simple write a script to manage,

01, the implementation of personnel additional operations

# Add AMD Delete card #coding =utf-8wfile=open (' Account.dat ') readfile=wfile.read () print "Please enter the new membership information. "Print" Membership information such as: C07004,DDDD, torpor, 2,020353,,,,,,,,,, "print" C07004: Membership number "print" DDDD: company abbreviation "print" torpor: member name "print" 2: Department " Print "020353, Time Card number" print "must be followed by 10,,,,,,,,,," Infile=raw_input (' Please enter new members: ') out=open (' Account.dat ', ' W ') Out.write ( Readfile+ ' \ n ') #out. Write ("\ n") Out.writelines ([Infile.strip ()]) Out.close ()

02, implement query Delete function

#delete Card#coding=utf-8import Shutildela = raw_input (' Please enter the Employee: ') with open (' Account.dat ', ' R ') as F:with open (' test.t Xt.new ', ' W ') as G:for line in F.readlines (): If Dela not in Line:g.write ( Line) shutil.move (' test.txt.new ', ' Account.dat ')


python-01, automatically write files

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.