#循环打开(如果没有创建文件)csv文档,w=写入,encoding编码,newline 删除隔行(excel打开的不是word,没写但是原理差不多,需要安装插件) with open("book.csv","w",encoding='gb18030',newline='') as datacsv:
csvwriter = csv.writer(datacsv,dialect=("excel"))
csvwriter.writerow(["名称","描述","作者/出版社/价格","评分","评分人数"]) for item in list:
csvwriter.writerow([item['name'],item['dec'],item['pub'],item['rating_nums'],item['people']])