多进程抓取猫眼电影+中文形式保存
def main():
pass
def write_to_file(content):
with open('result.txt','a',encoding='utf-8') as f:
f.write(json.dumps(content,ensure_ascii=False)*'\n')
f.close()
from multiprocessing import Pool
if __name__ == '__main__':
pool=Pool()
#构建了进程池,并运行了
pool.map(main,[i*10 for i in range(10)])