PYTHON168 's study notes 5

Source: Internet
Author: User

About the operation of the CSV file.

The Python standard library has a CSV library that is easy to use.

1 ImportCSV2 3With open ('Pingan.csv','RB') as RF:4Reader =csv.reader (RF) #读操作5With open ('Pingan2.csv','WB') as WF:6writer =Csv.writer (WF)7headers =Reader.next ()8 Writer.writerow (headers) #写操作9          forRowinchReader:Ten             ifRow[0] <'2016-01-01': #满足条件就退出循环 One                  Break A             ifInt (row[5]) >= 50000000: #对特定数据的判断 -Writer.writerow (Row)

About the operation of the JSON file.

There are also JSON libraries in the Python standard library, which are also easy to operate.

1 ImportJSON2 3L = (1, 2,'ABC',{'name':'John',' Age': 18})4 5With open ('Demo.json','WB') as F:6 json.dump (l,f)7     8With open ('Demo.json','RB') as F:9R =json.load (f)  

PYTHON168 's study notes 5

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.