这似乎是一个非常简单的问题。我安装了folium就好了但是我的程序在import语句中出现语法错误。
Traceback (most recent call last):
File "/home/python_scripts/interactivemap.py", line 3, in <module>
import folium as f
File "/usr/lib/python2.6/site-packages/folium/__init__.py", line 6, in <module>
from folium.folium import Map, initialize_notebook
File "/usr/lib/python2.6/site-packages/folium/folium.py", line 23, in <module>
from folium import utilities
File "/usr/lib/python2.6/site-packages/folium/utilities.py", line 235
json_data = [{type_check(x): type_check(y) for x, y in iteritems(data)}]
^
SyntaxError: invalid syntax
我真的很遗憾可能造成这种情况的原因除了我运行python 2.6这个事实,但我没有看到任何迹象表明这样的问题。
答案 0 :(得分:0)
当您使用Python 2.6时,您需要手动创建字典:
d = dict()
for k,v in iteritems(data): # Not sure where you got
# this method from
d[type_check(k)] = type_check(v)
json_data = [d] # or import simplejson as json; json_data = json.dumps(d)