私は現在、Python (Ubuntu 上) でビジュアル トレース ルート プログラムに取り組んでいます。私はpygeoipを使用して座標を取得しています(他の情報の中でも)。各 IP のデータをリスト (listcoor) に保存しています。私が抱えている問題は、リストコアに配置された特定の辞書項目にアクセスすることです
def vargeolocating(matchob): # matchob is a list of IPs
print "Geolocating IP addresses"
gi = GeoIP.open("/usr/share/GeoIP/GeoLiteCity.dat",GeoIP.GEOIP_STANDARD)
i = 0
listcoor = []
while ( i < len(matchob)):
holder = gi.record_by_addr(matchob[i])
if holder is None:# for local addresses
print "None"
else:
listcoor.append(holder)
i = i + 1
print holder['longitude'] # Prints out the last longitude
print listcoor[12] # Prints all information about the last IP (this longitude matchs the above longitude
print listcoor[12['longitude']] # Should print just the longitude, matching the two longitudes above
最後の出力には、「TypeError: 'int' object has no attribute ' getitem '」というエラーが表示されます。