python 编写输出到csv

	def test_write(self):
		fields=[]
		fields.append(orderCode)
		with open(r'./test001.csv', 'a',newline="") as f:
			writer = csv.writer(f)
			writer.writerow(fields)

定义一个列表:然后将需要写的数据添加到列表

a #追加数据到下一行

newline=''  //去除每一行中间的空行,若不加的话,行与行中间有空格

加newline

不加:

猜你喜欢

转载自blog.csdn.net/qq_43422918/article/details/92795804