基于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)
---------------------

转载于:https://www.cnblogs.com/ly570/p/11322895.html

发布了0 篇原创文章 · 获赞 16 · 访问量 5万+
展开阅读全文
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览