python 操作csv
python 操作csv
写csv
import csv with open('path/to/file.csv', 'w', newline='') as csvfile: writer = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) writer.writerow(['Name', 'Age', 'Gender']) writer.writerow(['Alice', '25', 'Female']) writer.writerow(['Bob', '30', 'Male'])
读csv
import csv with open('path/to/file.csv', newline='') as csvfile: reader = csv.reader(csvfile, delimiter=',', quotechar='"') for row in reader: print(', '.join(row))
##################
QQ 3087438119