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()行 –
没有,我工作了...... :) –