我创建代码来生成一个CSV文件,其中包含2013年全年间隔为1小时的日期和时间戳。我的代码是:
from datetime import *
moment=datetime(2013,1,1,0,50)
f = open ("C:\\dates.csv", "w")
while moment<datetime(2014,1,1):
f.write(str(moment.year)+"."+str(moment.month)+"."+str(moment.day)+";"+str(moment.hour)+":"+str(moment.minute)+"\n")
moment+=timedelta(minutes=+60)
f.close
问题是代码应该生成2013年全年的代码,但在2013年12月19日01:50之后就停止生成了。我找不到为什么。什么可能是问题所在?在
将第四行改为:
相关问题 更多 >
编程相关推荐