为什么在python 3.7.3中接收到urlopen no attribute error?

为什么在python 3.7.3中接收到urlopen no attribute error?,python,urllib,urlopen,simplejson,Python,Urllib,Urlopen,Simplejson,我是python新手,正在尝试处理地理代码数据 我已经编写了以下代码来查找到地理代码之间的驾驶时间 import urllib.request #from urllib.request import urlopen import simplejson, urllib orig_lat = 52.2296756 orig_lng = 21.0122287 dest_lat = 52.406374 dest_lng = 16.9251681 orig_coord = orig_lat, orig_l

我是python新手,正在尝试处理地理代码数据

我已经编写了以下代码来查找到地理代码之间的驾驶时间

import urllib.request
#from urllib.request import urlopen
import simplejson, urllib
orig_lat = 52.2296756
orig_lng = 21.0122287
dest_lat = 52.406374
dest_lng = 16.9251681
orig_coord = orig_lat, orig_lng
dest_coord = dest_lat, dest_lng
url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins={0}&destinations={1}&mode=driving&language=en-EN&sensor=false".format(str(orig_coord),str(dest_coord))
result= simplejson.load(urllib.urlopen(url))
driving_time = result['rows'][0]['elements'][0]['duration']['value']
但是,我收到一个错误:

Traceback (most recent call last):

  File "<ipython-input-154-c5d2043b6825>", line 11, in <module>
    result= simplejson.load(urllib.urlopen(url))

AttributeError: module 'urllib' has no attribute 'urlopen'

我看过其他关于这方面的帖子,但没有一篇能解决这个属性错误

假设您使用的是Python3,urllib.urlopen已与urllib.request.urlopen一起使用。将urllib.urlopenurl更改为urllib.request.urlopenurl


有关更多信息,请参阅。

您好,欢迎使用SO!你还参考了哪些帖子?它的python 3.7.3然后使用我建议的方法