试图从网络上获取geojson文件的geojson文件。
req = requests.get('https://raw.githubusercontent.com/python-visualization/folium/master/examples/data/world-countries.json')
req = req.text
geofile = json.load(open(req))
print(geofile)
但是在上面的代码片段中获得了以下追溯:
OSError Traceback (most recent call last)
<ipython-input-11-0a17bd75da0e> in <module>
6 req = requests.get('https://raw.githubusercontent.com/python-visualization/folium/master/examples/data/world-countries.json')
7 req = req.text
----> 8 geofile = json.load(open(req))
9
10 print(geofile)
OSError: [Errno 36] File name too long:
[不确定您为什么需要open
任何东西...仅阅读文档就足以知道如何发出请求https://2.python-requests.org/en/master/
result = req.get("https://raw.githubusercontent.com/python-visualization/folium/master/examples/data/world-countries.json")
data = result.json()
print(data)