1
我從一個文件中讀取了更多的千位座標,爲此我想獲取相關國家。我試圖殺死時間限制,但它不起作用,它在150-160座標後停止。我可以處理這個嗎?Python,geopy kill time limit
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, sys
with open('alagridsor.txt') as f:
lines = f.read().splitlines()
for sor in range(1, 9271):
print(sor)
koor = lines[sor]
from geopy.geocoders import Nominatim
from geopy.exc import GeocoderTimedOut
geolocator = Nominatim()
location = geolocator.reverse(koor, timeout=None)
cim = location.raw['address']['country']
print(cim)
f = open('out.txt', 'a')
f.write(cim.encode('utf8'))
f.write("\n")
非常感謝您!我會盡快嘗試... –
它寫道:「預計一個縮進塊」爲koor.rstrip()行 –
沒有,我工作了...... :) –