#-*-coding:utf-8-*-
import requests
import json

file = 'Sessions.dat'
with open(file,encoding='utf-16') as f:
	lines = f.readlines()
	len=len(lines)
	with open('comments831.txt','a') as file:

		for i in range(0, len):  # range防止下标越界
			try:
				comm = json.loads(lines[i])
				for j in range(100):
					print(j,comm['response_data']['comments'][j]['text'])
					print(comm['response_data']['comments'][j]['user']['short_id'])
					file.write(comm['response_data']['comments'][j]['text']+'\n')
					file.write(comm['response_data']['comments'][j]['user']['short_id']+'\n')

在这里插入图片描述
我v:yummoo

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐