python中csv文件的读写
来源:互联网 发布:搜苹果软件下载 编辑:程序博客网 时间:2024/05/22 12:38
*说明:在Linux下实现,Windows下可能会有所不同(文件内容会有区别,比如会出现莫名其妙的空行)
一、写文件
with open("test.csv","w") as c: writer=csv.writer(c) writer.writerow(['name','address','city','state'])
将字符串挨个输入文件中,结果如图
也可以将一个list写到文件中
l=[]l.append([1,2,3])l.append([4,5,6])l.append([7,8,9])with open("test.csv","w") as c1: writer=csv.writer(c1) for idx in l: writer.writerow(idx)
文件结果
二、读文件
比如文件中内容是下图
with open("test.csv","r") as c1: lines=csv.reader(c1) for line in lines: print(line)
输出结果
阅读全文
0 0
- python中csv文件的读写
- python中读写csv文件的方法
- python中csv文件的若干读写方法
- Python读写csv文件
- python 读写 csv文件
- Python读写csv文件
- Python读写csv文件
- Python读写csv文件
- Python读写csv文件
- Python读写csv文件
- Python读写csv文件
- Python读写csv文件
- Python读写csv文件
- Python读写csv文件
- python读写csv文件
- Python 读写CSV文件
- python 读写csv文件
- python 读写CSV 文件
- 最小二乘法简介
- SVG系列 — 动画元素<animate>
- Xcode 控制台输出不全 ,NSLong输出小技巧,NSLog输出中文,json格式错误
- sbt使用详解
- 《java高并发程序设计》读书笔记(3)
- python中csv文件的读写
- Android历史版本及和eclipse基本区别
- git使用
- Linux 4.x 之Gpio分析(一)Gpiolib库1
- 【游戏文案入门常识】三、游戏世界观的搭建
- 初识分布式服务框架dubbo
- matlab中矩阵的创建
- k-折交叉验证(k-fold crossValidation)
- 使用LLDB调试Swift