以下总结爬虫中常用的文件写入方法。 (1) with open('test.csv','w',encoding='utf-8',newline='') as csvfile: #设置列名 fieldname = ['website','name'] write = csv.DictWriter(csvfile,fieldnames=fieldname) #先将头写入表中 write.writeheader() for result in results: # result是一个字典类型,依次取出我们的每一个值 website &#