python3.3 urlopen失败?
2013-03-04 00:00
267 查看
import tkinter
import urllib
class Window:
def __init__(self,root):
self.root = root
self.entryUrl = tkinter.Entry(root)
self.entryUrl.place(x=5,y=13)
self.get = tkinter.Button(root,text='xia',command= self.Get)
self.get.place(x=120,y=13)
self.edit = tkinter.Text(root)
self.edit.place(y=50)
def Get(self):
urlq = self.entryUrl.get()
page = urllib.urlopen(urlq)
data = page.read()
self.edit.insert(tkinter.END,data)
page.close()
root = tkinter.Tk()
window = Window(root)
root.minsize(600,800)
root.mainloop()
提示
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1442, in __call__
return self.func(*args)
File "C:\Documents and Settings\Administrator\桌面\d.py", line 14, in Get
page = urllib.urlopen(urlq)
AttributeError: 'module' object has no attribute 'urlopen'
urlopen怎么会找不到呐?很郁闷
找到问题了,原来导入的时候要用
import urllib.request
import urllib
class Window:
def __init__(self,root):
self.root = root
self.entryUrl = tkinter.Entry(root)
self.entryUrl.place(x=5,y=13)
self.get = tkinter.Button(root,text='xia',command= self.Get)
self.get.place(x=120,y=13)
self.edit = tkinter.Text(root)
self.edit.place(y=50)
def Get(self):
urlq = self.entryUrl.get()
page = urllib.urlopen(urlq)
data = page.read()
self.edit.insert(tkinter.END,data)
page.close()
root = tkinter.Tk()
window = Window(root)
root.minsize(600,800)
root.mainloop()
提示
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1442, in __call__
return self.func(*args)
File "C:\Documents and Settings\Administrator\桌面\d.py", line 14, in Get
page = urllib.urlopen(urlq)
AttributeError: 'module' object has no attribute 'urlopen'
urlopen怎么会找不到呐?很郁闷
找到问题了,原来导入的时候要用
import urllib.request
相关文章推荐
- windows和linux下使用python2.7 urllib.urlopen+beautifulsoup打开12306网站订票页面表现不同,前者报错ssl认证失败,后者成功
- window7下配置python2.7+tornado3.3开发环境
- Python3与OpenCV3.3 图像处理(十五)--图像二值化
- CentOS升级Python到3.3,系统仍然使用默认的2.6的解决办法
- python pip安装模块失败
- python递归分治求最大子数组失败
- Mac OS X10.9安装的Python2.7升级Python3.3步骤详解
- Python3.3 学习笔记7 - 控制语句
- Windows下OpenCV3.3 + Python3.6 开发环境配置
- postgresql CREATE Language plpython3u 失败
- python3.3 系统路径
- 深入学习python (五) 当pip install 失败抛锚时该怎么办
- 【Python-3.3】字典存储调查问卷
- Python2.7-pip install MySQL-python失败的问题
- python3关于urllib中urlopen报错问题的解决
- 如何在python3.3用 map filter reduce
- 使用 CMake + VS2017 ( + Python 3) 配置和编译 OpenCV 3.3
- Python3与OpenCV3.3 图像处理(十六)--图像金字塔
- Python3.3 print函数用法,print 格式化输出
- 如何在Django1.6结合Python3.3版本中使用MySql