Python Learning Notes (15) Get local data with Python

Source: Internet
Author: User

F1 = open (R'E:\Python\Data\data1.txt')  # reads the data1.txt file, using the system default buffer size, To read fast, use cache! 

f = Open (r'E:\Python\Data\data2.txt','W') F.write ('Hello World!') F.close () F= Open (R'E:\Python\Data\data2.txt','R') P1= F.read (5)#Read 5 bytes FirstP2 = F.read ()#read all the rest.
f.close ()
File_obj.readlines (), File_obj.readline (), File_obj.writelines ()
f = open (R'E:\Python\Data\data3.txt'= F.readlines ()   #  Reads data from a line of files, returns a list of print(cnames) f.close ()
# As a result, readlines () reads the result without removing the line break ['GOOGLE inc\n'nicrosoft corporation\n'  Apple inc.\n'Facebook, Inc. ']

#Filename:revcopy.pyF1 = Open (r'E:\Python\Data\data3.txt') # read cnames=F1.readlines () forIinchRange (0, Len (cnames)): Cnames[i]= str (i+1) +'.'+cnames[i]f1.close () F2= Open (R'E:\Python\Data\data3_out.txt','W') # write f2.writelines (cnames) f2.close ()

' Tencent technology company Limited '  = open (R'E:\Python\Data\data3.txt' a+') F.writelines ('\ n') f.writelines (s)f.seek (0, 0)            # Move the file pointer to the file header  = f.readlines ()print(cnames) f.close ()

Python Learning Notes (15) Get local data with Python

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.