2016-07-24 16 views
-3

私はPython 3.4.2をLinuxで使用しています。Python urllibでlocalhostを開くことができません

myurl = 'http://localhost/test.php' 
response = urllib.urlopen(myurl) 

while response.text != 'exit': 
    response = urllib.urlopen(myurl) 

と私はモジュールがurllib.request.urlopenあるのpython 3では、このエラー

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' 
+1

below-示すようにPythonで[ 'urllib.request.urlopen'(https://docs.python.org/3/library/urllib.request.html#module-urllib.request)それを使用3 –

答えて

1

を得ました。

import urllib.request 
# and then 
response = urllib.request.urlopen(myurl) 
関連する問題