📅  最后修改于: 2022-03-11 14:46:06.533000             🧑  作者: Mango
import os
def set_proxy():
proxy_addr = 'http://{user}:{passwd}@{address}:{port}'.format(
user='user_example', passwd='pass_example',
address='address_example', port=int('port_example'))
os.environ['http_proxy'] = proxy_addr
os.environ['https_proxy'] = proxy_addr
def unset_proxy():
os.environ.pop('http_proxy')
os.environ.pop('https_proxy')
set_proxy()
geolocator = GoogleV3()
location = geolocator.geocode('%s, %s' % (latitude, longitude), timeout=10)
address = location.address
unset_proxy()