googlemapsで地域を指定して以下のような、結果を得られたのですが、この中のplace_idのみを抽出し取得する場合、codeはどのようにしたらいいのでしょうか?
試したこととして、
for result in results.items(): print(result["place_id"])
for result in results.items(): print(result[0]["place_id"])
など変えたりしましたが、指定するコードが違うと言われてしまします。(結果はresultに格納されています)
pythonを始めたばかりで、よくわかっていない身なので、教えていただけたら幸いです。
{'html_attributions': [], 'results': [{'name': 'Sizzler シズラー新宿三井ビル店', 'plus_code': {'compound_code': 'MMRV+GF Tokyo, Japan', 'global_code': '8Q7XMMRV+GF'}, 'geometry': {'viewport': {'northeast': {'lat': 35.69267862989271, 'lng': 139.6950139298928}, 'southwest': {'lat': 35.68997897010727, 'lng': 139.6923142701073}}, 'location': {'lat': 35.6913288, 'lng': 139.6936641}}, 'scope': 'GOOGLE', 'vicinity': 'Shinjuku, Nishishinjuku, 2 Chome−2-1 新宿三井ビル', 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png', 'price_level': 1, 'reference': 'ChIJGc0EANWMGGARilX_E8Dyv_A', 'types': ['restaurant', 'point_of_interest', 'food', 'establishment'], 'photos': [{'html_attributions': ['<a href="https://maps.google.com/maps/contrib/115665929955581317240/photos">山雲海月</a>'], 'photo_reference': 'CmRaAAAAcJJrmwTd0cjdowtM_yGHcmDm32TRhGv1YrPBPvFkq_0ipXOAtdyqjyNv3G79Slqc1dYw6mjQXm06LKifJmEVkniehdMtvqgk4-MjtQ9NuadxoxG-JbUWDsF6KZBkybKnEhAlId-knT5DVHGEjGxBIXXSGhQF5fhEsB8o45fG6L_QLgEWV6SAxA', 'height': 3024, 'width': 4032}], 'opening_hours': {'open_now': False}, 'rating': 4.1, 'place_id': 'ChIJGc0EANWMGGARilX_E8Dyv_A', 'id': '254062c4dc01c0d499fd64e321af03f3b65118d4'}, {'name': 'Tenkane', 'plus_code': {'compound_code': 'MMVX+26 Tokyo, Japan', 'global_code': '8Q7XMMVX+26'}, 'geometry': {'viewport': {'northeast': {'lat': 35.69397152989273, 'lng': 139.6994352298927}, 'southwest': {'lat': 35.69127187010729, 'lng': 139.6967355701073}}, 'location': {'lat': 35.6926217, 'lng': 139.6980854}}, 'scope': 'GOOGLE', 'vicinity': 'Shinjuku, Nishishinjuku, 1 Chome−5−1 小田急ハルク', 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png', 'reference': 'ChIJ_fFg4taMGGARzkeRkpAV6u0', 'types': ['restaurant', 'point_of_interest', 'food', 'establishment'], 'photos': [{'html_attributions': ['<a href="https://maps.google.com/maps/contrib/109599553306756371404/photos">天兼</a>'], 'photo_reference': 'CmRaAAAAGETjjm-PIWW27Rt5eGs6FdWbJNRPdybvzlo2a0AOiO0OrLM-fxRzHC1KrwM5BO4gvSCPy22g2BLtsnqozDKO-Kv0wrwmcfgJRmiFBhOh9LDfmFyeKHFPyGG3nfePW-fJEhDSg7NYljSEknYO37QuAoTPGhQEnhu6lBJaGdU4GZt6zoZnO4cSXg', 'height': 3456, 'width': 5184}], 'opening_hours': {'open_now': False}, 'rating': 4.2, 'place_id': 'ChIJ_fFg4taMGGARzkeRkpAV6u0', 'id': '3c15e0a973d2ed6f3964568be221a2d4fb5739dc'}, {'name': 'Kyubey', 'plus_code': {'compound_code': 'MMQV+XR Tokyo, Japan', 'global_code': '8Q7XMMQV+XR'}, 'geometry': {'viewport': {'northeast': {'lat': 35.69133442989271, 'lng': 139.6959166298927}, 'southwest': {'lat': 35.68863477010727, 'lng': 139.6932169701072}}, 'location': {'lat': 35.6899846, 'lng': 139.6945668}}, 'scope': 'GOOGLE', 'vicinity': '2 Chome-2-1 Nishishinjuku, Shinjuku', 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png', 'price_level': 4, 'reference': 'ChIJYajoqNWMGGAR1nMWq8LhORc', 'types': ['restaurant', 'point_of_interest', 'food', 'establishment'], 'photos': [{'html_attributions': ['<a href="https://maps.google.com/maps/contrib/100681263405083764994/photos">T Y</a>'], 'photo_reference': 'CmRaAAAAzMY4f7UPz4_xYS_ygdl03tISHk8C-tnW-2e4K2_g7XMIjeuhuSwEhJjbjyccVyH2UlAl8l8KWLLDZzpEsjyHrycJbHGctivz1hBqQOp6lhQL3LF-tJ6udEc5ro0peoPbEhCqNYxBMUfkUeJejhnzYX24GhQaGWbA2bs3GhV88EHcumGLC3ivog', 'height': 3024, 'width': 4032}], 'opening_hours': {'open_now': False}, 'rating': 4.4, 'place_id': 'ChIJYajoqNWMGGAR1nMWq8LhORc', 'id': 'd92761b5e8807c4a48c00fa2ac1c216e4a7c1411'}, {'name': '誠寿司', 'plus_code': {'compound_code': 'MMVV+CM Tokyo, Japan', 'global_code': '8Q7XMMVV+CM'}, 'geometry': {'viewport': {'northeast': {'lat': 35.69494272989272, 'lng': 139.6955123298927}, 'southwest': {'lat': 35.69224307010727, 'lng': 139.6928126701073}}, 'location': {'lat': 35.6935929, 'lng': 139.6941625}}, 'scope': 'GOOGLE', 'vicinity': 'Shinjuku, Nishishinjuku, 6-2−3−103', 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png', 'reference': 'ChIJv3LyhtWMGGAR6a4klzW2pdA', 'types': ['restaurant', 'point_of_interest', 'food', 'establishment'], 'photos': [{'html_attributions': ['<a href="https://maps.google.com/maps/contrib/105939611760802714209/photos">Evan Knox</a>'], 'photo_reference': 'CmRaAAAAhoThpOZm1bndNDM4OcaqIcTDQ57BRV-UiGVDWg67Wyp6aai_zWUKQgtWxcEv9wtZcTOuzG9vU6RFMlXhzO_kn5j_8XjQs0ri5lwgiVDPqa3yFwShbcIoG0K3Sg9cr-5kEhAiRZ6v5vQ7IXeB0UZ0b9ZFGhSoMB2ZPNvhef9ZLojSeDgZf-XvFg', 'height': 3024, 'width': 4032}], 'opening_hours': {'open_now': False}, 'rating': 4.4, 'place_id': 'ChIJv3LyhtWMGGAR6a4klzW2pdA', 'id': 'feecd91705fdb718541dca241050d39ba6be9e58'}], 'status': 'OK'}
回答1件
あなたの回答
tips
プレビュー