我在linux上使用Python 3.4.2是我的代码。
myurl = 'http://localhost/test.php'
response = urllib.urlopen(myurl)
while response.text != 'exit':
response = urllib.urlopen(myurl)
我收到了这个错误
Traceback (most recent call last) :
File "/var/www/html/led.py", line 19, in <module>
response = urllib.urlopen(myurl)
AttributeError: 'module' object has no attribute 'urlopen'
答案 0 :(得分:1)
在python 3中,模块是urllib.request.urlopen
。使用它如下所示 -
import urllib.request
# and then
response = urllib.request.urlopen(myurl)