Python csv.writerow([])跨两行?

时间:2014-03-08 05:35:13

标签: python csv

我的代码是:

c = csv.writer(open("addresses.csv",  "wb"), quoting=csv.QUOUTE_ALL)
temp = open("temp_address.txt") //this contains a string, like this "1234567890ABCDEF"
c.writerow([temp.read(), "customers withdraw"])

.csv文件以此结尾

"1234567890ABCDEF
","Customers widthraw"

为什么会这样?我很感激帮助修复这个

1 个答案:

答案 0 :(得分:2)

看起来该文件最后有一个换行符。您可能希望.strip()结果。

e.g:

c.writerow([temp.read().strip(), "customers withdraw"])