为什么会看到“ TypeError:字符串索引必须为整数”?
我正在学习python并试图将github问题转换为可读形式。使用有关如何将JSON转换为CSV的建议?我想出了这个: import json import csv f=open('issues.json') data = json.load(f) f.close() f=open("issues.csv","wb+") csv_file=csv.writer(f) csv_file.writerow(["gravatar_id","position","number","votes","created_at","comments","body","title","updated_at","html_url","user","labels","state"]) for item in data: csv_file.writerow([item["gravatar_id"], item["position"], item["number"], item["votes"], item["created_at"], item["comments"], item["body"], item["title"], item["updated_at"], item["html_url"], item["user"], item["labels"], item["state"]]) 其中“ issues.json”是包含我的github问题的json文件。当我尝试运行它时,我得到 File "foo.py", line 14, in <module> csv_file.writerow([item["gravatar_id"], item["position"], item["number"], item["votes"], item["created_at"], item["comments"], item["body"], item["title"], item["updated_at"], item["html_url"], item["user"], item["labels"], …