脚本语言:Python的3.6Python书籍典型的错误: “字符串incides必须是整数”
参考教材:Python的数据可视化食谱[Milovanovic的2013年11月25日]
自学Python数据可视化
当我从书执行代码
import requests
url = 'https://github.com/timeline.json'
r = requests.get(url)
json_obj = r.json()
repos = set() # we want just unique urls
for entry in json_obj:
try:
repos.add(entry['repository']['url'])
except KeyError as e:
print ("No key %s. Skipping..." % (e))
from pprint import pprint
pprint(repos)
我收到错误
repos.add(entry['repository']['url'])
TypeError: string indices must be integers
如何解决故障?当我看到similar threads,我画一个空白
是从书中甚至正确的代码?
[作为repos = set()
顺便说一句,在哪里设置()是从哪里来的?]
请点我在正确的方向
来自json_obj: 你好,那里有陌生人。如果你正在阅读这篇文章,那么你可能几年前没有看到我们的博客文章宣布这个API会消失:http://git.io/17AROg不要担心,你应该能够得到你需要的东西从闪亮的新事件API而不是。 –