从地码响应中提取坐标

2024-04-26 12:26:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图获得坐标的位置使用自由形式的方法在这里。这个函数以Json的形式返回一个数据列表(据我所知)。我想从这个列表中提取一些数据。我试过使用json.loads文件()但它返回以下错误:

TypeError: the JSON object must be str, bytes or bytearray, not 'GeocoderResponse'

数据如下所示:

{"Response": {"MetaInfo": {"Timestamp": "2019-06-02T16:46:46.588+0000"}, "View": [{"Result": [{"Location": {"Address":{"AdditionalData": [{"key": "CountryName", "value": "Nederland"}, {"key": "StateName", "value": "Noord-Holland"}, {"key": "CountyName", "value": "Haarlemmermeer"}], "City": "Nieuw-Vennep", "Country": "NLD", "County": "Haarlemmermeer", "Label": "Nieuw-Vennep, Noord-Holland, Nederland", "PostalCode": "2151 AR", "State": "Noord-Holland"}, "DisplayPosition":{"Latitude": 52.26388, "Longitude": 4.62986}, "LocationId": "NT_.gc2w3DtLRjNeEZj3hDvIB", "LocationType": "point", "MapView": {"BottomRight": {"Latitude": 52.25047, "Longitude": 4.65622}, "TopLeft": {"Latitude": 52.28503, "Longitude": 4.59986}}, "NavigationPosition": [{"Latitude": 52.26388, "Longitude": 4.62986}]}, "MatchLevel": "city", "MatchQuality": {"City": 0.5}, "Relevance": 1.0}], "ViewId": 0, "_type": "SearchResultsViewType"}]}}

或者。。。你知道吗

{'Response': {'MetaInfo': {'Timestamp': '2019-06-02T16:46:46.588+0000'},
              'View': [{'Result': [{'Location': {'Address': {'AdditionalData': [{'key': 'CountryName',
                                                                                 'value': 'Nederland'},
                                                                                {'key': 'StateName',
                                                                                 'value': 'Noord-Holland'},
                                                                                {'key': 'CountyName',
                                                                                 'value': 'Haarlemmermeer'}],
                                                             'City': 'Nieuw-Vennep',
                                                             'Country': 'NLD',
                                                             'County': 'Haarlemmermeer',
                                                             'Label': 'Nieuw-Vennep, '
                                                                      'Noord-Holland, '
                                                                      'Nederland',
                                                             'PostalCode': '2151 '
                                                                           'AR',
                                                             'State': 'Noord-Holland'},
                                                 'DisplayPosition': {'Latitude': 52.26388,
                                                                     'Longitude': 4.62986},
                                                 'LocationId': 'NT_.gc2w3DtLRjNeEZj3hDvIB',
                                                 'LocationType': 'point',
                                                 'MapView': {'BottomRight': {'Latitude': 52.25047,
                                                                             'Longitude': 4.65622},
                                                             'TopLeft': {'Latitude': 52.28503,
                                                                         'Longitude': 4.59986}},
                                                 'NavigationPosition': [{'Latitude': 52.26388,
                                                                         'Longitude': 4.62986}]},
                                    'MatchLevel': 'city',
                                    'MatchQuality': {'City': 0.5},
                                    'Relevance': 1.0}],
                        'ViewId': 0,
                        '_type': 'SearchResultsViewType'}]}}

Tags: 数据keycity列表valueresponse形式latitude