for i in range(10):
url = baseUrl.format(str(i+1))
res = requests.get(url, headers)
print(res.status_code)
infoStr = res.text
with open(sourcePath, 'a+', encoding='utf-8') as f:
f.write(str(infoStr) + '\n')
f.close()
file = open(sourcePath)
for line in file:
returnValue = json.loads(line)
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
你检查一下你的txt数据是完整的json格式数据吗
f.write(str(infoStr) + '\n')
你写文件的时候都不是用json dumps写入的。
用json 读肯定失败呀。