`
talw
  • 浏览: 10751 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

python中的csv

阅读更多
目前,python的csv包还不能直接处理utf文档,所以读出后必须处理以下
python 代码
 
  1. for row in reader:
    1. yield [unicode(cell, 'utf-8') for cell in row]  
如果要将含有中文ANSI文档的内容添加到数据库中,也是一样的
python 代码
 
  1. for row in reader:
    1. yield [unicode(cell, 'gb2312') for cell in row]  
分享到:
评论
1 楼 yanzixiang 2008-12-22  
这个要看你的文件是用什么编码保存的,如果直接用utf8保存的话,就不存在这些问题,建议使用openoffice

相关推荐

Global site tag (gtag.js) - Google Analytics