【发布时间】:2017-08-17 13:51:16
【问题描述】:
我从一个文件中读取了更多的千坐标,因为我想获得相关的国家。我试图杀死时间限制,但它还没有起作用,它在 150-160 坐标后停止。我可以处理吗?
#!/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")
【问题讨论】: