我有以下字典(Geojson):
'properties': {
'fill': '#ffffff', 'fill-opacity': 1, 'stroke': '#ffffff',
'stroke-opacity': 1, 'stroke-width': 1.5, 'title': '0.00 m',
'time': '2000-01-31'
}
通过将某些值移动到属性中的新键,将是最简单的方法如下。
'properties': {
'style': {
'fill': '#ffffff', 'fill-opacity': 1, 'stroke': '#ffffff',
'stroke-opacity': 1, 'stroke-width': 1.5, 'title': '0.00 m'
},
'time': '2000-01-31'
}
}
任何反馈将有所帮助。谢谢。
你可以弹出的time
和建立这样一个新的字典:
properties = {
'fill': '#ffffff', 'fill-opacity': 1, 'stroke': '#ffffff',
'stroke-opacity': 1, 'stroke-width': 1.5, 'title': '0.00 m',
'time': '2000-01-31'
}
time = properties.pop('time')
new_properties = {'style': properties, 'time':time}
print(new_properties)
# {'style': {'fill': '#ffffff', 'fill-opacity': 1, 'stroke': '#ffffff',
# 'stroke-opacity': 1, 'stroke-width': 1.5, 'title': '0.00 m'},
# 'time': '2000-01-31'}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句