2.7 CSV module wants unicode, but doesn't want unicode

后端 未结 3 1638
余生分开走
余生分开走 2021-02-19 08:01
csvfile_ = open(finishedFileName+num+\".csv\",\"w\",newline=\'\')
writ = csv.writer(csvfile_, dialect=\'excel\')
firstline = unicode(str(firstline))
try:
    writ.writer         


        
3条回答
  •  感动是毒
    2021-02-19 08:19

    I had the same problem with open() and csv. A friend gave me the solution, which is to use open_output() instead of open(). open_output() defaults to "wb" instead of text.

提交回复
热议问题