前提・実現したいこと
GeoIPとパイソンを使用して,IPアドレスに対応した国名が知りたいです.エラーがよくわかりません.
発生している問題・エラーメッセージ
Traceback (most recent call last): File "C:/Users/a/Downloads/GeoLite2-City_20190806.tar/GeoLite2-City_20190806/GeoLite2-City_20190806/3.py", line 2, in <module> import geoip2.database File "C:/Users/a/Downloads/GeoLite2-City_20190806.tar/GeoLite2-City_20190806/GeoLite2-City_20190806\geoip2.py", line 1 Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 ^ SyntaxError: invalid syntax
該当のソースコード
import sys import geoip2.database ipaddress=sys.argv[1] reader = geoip2.database.Reader('GeoLite2-City_20180403/GeoLite2-City.mmdb') response = reader.city(ipaddress) print(response.country) print(response.country.names["en"]) print(response.country.iso_code)
試したこと
必要なデータ(Geolite2-City.mmdbなど)は入れています.
powershellでpip install geoip2は実行済みです.
補足情報(FW/ツールのバージョンなど)
windows10
宜しくお願いします。
参考にしたサイトなどあれば提示ください。
また、エラーで示されている「3.py」「geoip2.py」のソースコード内容を提示ください。
回答1件
あなたの回答
tips
プレビュー