我有以下代码,其中正在将一些数据写入 .csv 文件并读取它。当脚本在 Windows 上运行时,数据被写入如下,当相同的脚本被添加时,添加了一个带有空格的新行在linux上运行没有空格..任何人都可以提供为什么会这样的输入吗?
趋势.csv
6/26/2013 9
6/26/2013 9
6/26/2013 9
import csv
import datetime
from collections import deque
#from collections import maxlength
icount=9
now = datetime.datetime.now()
time =now.strftime("%m/%d/%Y")
#Keep appending date and count everytime this script is run
c = csv.writer(open("trend.csv", "a"))
c.writerow([time, icount])
with open('trend.csv','rU') as fin:
reader=csv.reader(fin)
d=deque(reader,8)
print "Data"
print d
for l in d:
print l[0]
print l[1]