python-csv

 

# - * - Coding: UTF-. 8 - * - 
Import CSV # numeric string of numbers and can DATAS = [[ 'name' , 'Age' ] , [ 'Bob' , 14 ] , [ 'Tom' , 23 is ] , [ 'Jerry' , '18 is' ]] with Open ( 'example.csv' , 'W' , NEWLINE = '' ) AS F: Writer = csv.writer (F) for Row in DATAS: Writer.WriteRow (Row) # can also write multiple lines














writer.writerows (DATAS)

filename = 'example.csv'
with Open (filename) AS F:
reader = csv.reader (F)
# reads a line following the reader has no line
# head_row = next (reader)
for row in Reader:
# 2 start line number from
Print (reader.line_num , row)

Guess you like

Origin www.cnblogs.com/oracle614/p/11857521.html