![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/2cbe9c491fe82f3a770a682d04dcdc82.png)
存文件的三种方式:
txt文件
with open('目录.txt','a',encoding='utf-8') as f:
f.write(alist+'\n')
csv文件
with open('qdzw.csv','w',encoding='utf-8') as f:
writer = csv.writer(f,delimiter=',')
writer.writerow(['title','author','cont'])
with open('qdzw.csv','a',encoding='utf-8') as f:
writer = csv.writer(f, delimiter=',')
writer.writerow([title,author,cont])
json文件
lst = []
dic = {}
dic['title'] = title
dic['author'] = author
dic['cont'] = cont
lst.append(dic)
with open('qdzw.json', 'a', encoding='utf-8') as f:
f.write(json.dumps(lst, indent=4, ensure_ascii=False))