基于python实现自动化办公学习笔记一
1、CSV
(1)写csv文件
import csv
def writecsv(path,data):
with open(path, "w") as f:
writer = csv.writer(f)
for rowData in data:
print("rowData=", rowData)
writer.writerow(rowData)
path = r"E:\\Python\\py17\\automatictext\\000001.csv"
writecsv(path, [[1, 2, 3], [4, 5, 6], [7, 8, 9]])
1
2
3
4
5
6
7
8
9
10
11
12
(2)读csv文件
import csv
def readcev(path):
infolist = []
with open(path, "r") as f:
allFile = csv.reader(f)
for row in allFile:
infolist.append(row)
return infolist(http://www.amjmh.com/v/BIBRGZ_558768/)
path = r"E:\\Python\\py17\\automatictext\\PCB3.csv"
info = readcev(path)
---------------------