简体   繁体   English

JSON 处理:[Errno 36] 文件名太长

[英]JSON Handling: [Errno 36] File name too long

Trying to fetch a geojson file from the web for a folium choropleth map.试图从网络上获取一个 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)

But getting the following traceback on the above code snippit:但是在上面的代码片段上得到以下回溯:

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:

Not sure why you would need open anything... Simply readings docs is enough to know how to make requests https://2.python-requests.org/en/master/不知道为什么你需要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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM