Python写入CSV文件的方法
作者:光索与诺 时间:2021-08-21 19:09:44
本文实例讲述了Python写入CSV文件的方法。分享给大家供大家参考。具体如下:
# _*_ coding:utf-8 _*_
#xiaohei.python.seo.call.me:)
#win+python2.7.x
import csv
csvfile = file('csvtest.csv', 'wb')
writer = csv.writer(csvfile)
writer.writerow(['id', 'url', 'keywords'])
data = [
('1', 'http://www.xiaoheiseo.com/', '小黑'),
('2', 'http://www.baidu.com/', '百度'),
('3', 'http://www.jd.com/', '京东')
]
writer.writerows(data)
csvfile.close()
希望本文所述对大家的Python程序设计有所帮助。
标签:Python,CSV
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
从Vista地址栏到网站导航菜单
2009-09-08 12:35:00
![](https://img.aspxhome.com/file/UploadPic/20099/8/nav-62s.jpg)
asp生成带日期的随机数
2008-09-03 13:13:00
python读取json数据还原表格批量转换成html
2023-11-19 05:46:20
js表单提交显示进度条
2007-09-18 13:10:00
下载Internet Explorer 9 平台预览版4
2010-08-05 20:59:00
Python大数据之从网页上爬取数据的方法详解
2023-10-06 22:10:53
![](https://img.aspxhome.com/file/2023/3/72023_0s.png)
python实现对象列表根据某个属性排序的方法详解
2022-12-24 23:47:43
python列表中常见的一些排序方法
2023-08-17 08:48:45
python自动化测试中装饰器@ddt与@data源码深入解析
2021-10-08 16:07:14
![](https://img.aspxhome.com/file/2023/1/72951_0s.png)
Python实现图片格式转换
2023-08-03 04:58:57
![](https://img.aspxhome.com/file/2023/7/60967_0s.jpg)
Oracle学习笔记(四)
2012-01-05 18:57:33
iPhone应用设计趋势[译]
2009-11-27 19:52:00
一次性压缩Sqlserver2005中所有库日志的存储过程
2012-01-29 17:58:28
实现页面中按钮刷新的N种方法
2007-02-03 11:06:00
Python协程实践分享
2023-09-01 05:50:51
![](https://img.aspxhome.com/file/2023/5/62875_0s.png)
正在研究XMLHTTP如何正确传送大于7F(127)的二进制数据
2008-09-13 18:41:00
MYSQL启用日志和查看日志
2010-12-03 16:24:00
一个ASP记录集分页显示的例子
2007-09-14 10:57:00
向外扩展SQL Server 实现更高扩展性
2008-12-18 14:45:00
PHP手机号码归属地查询代码(API接口/mysql)
2023-10-26 04:35:44