import Gvalues
with open('D:\Projects\log\pode.csv', 'w', newline='') as GValues.csv_file:
writer1 = csv.DictWriter(GValues.csv_file, fieldnames=GValues.fieldnames)
writer1.writeheader()
while True:
print(time.strftime("%d/%m/%Y %H:%M:%S"))
GetStats.get_stats_method(GValues.pair_name, GValues.depth_level)
WriteCsv.write_csv(writer1)
下面的代码工作正常,但是当我把它放入while循环时它失败了。我能够运行该程序,但csv文件中没有数据。除了删除while循环并调整选项卡之外,我没有进行任何更改。
import Gvalues
with open('D:\Projects\log\pode.csv', 'w', newline='') as GValues.csv_file:
writer1 = csv.DictWriter(GValues.csv_file, fieldnames=GValues.fieldnames)
writer1.writeheader()
print(time.strftime("%d/%m/%Y %H:%M:%S"))
GetStats.get_stats_method(GValues.pair_name, GValues.depth_level)
WriteCsv.write_csv(writer1)