更新时间:2023-12-06 16:06:22
通过一些修补,我意识到您可以添加以下行,以确保您开始在csv中的新行中编写.虽然看起来有点黑.文档中提到了很多有关kwarg newline =''的内容,但并未被认为是有效的.
With some tinkering I realized you can add the following line to make sure you begin writing on a new line in a csv. Though it seems kind of hackish. Documentation mentions a lot about a kwarg newline='', but it wasn't recognized as valid.
writer.writerow([])
我也用'ab'参数打开.
I also open with 'ab' parameter.
import csv
with open('mycsvfile.csv','ab') as f:
writer=csv.writer(f)
writer.writerow([])
writer.writerow(['0','0','0'])