您的位置:首页 > 编程语言 > Python开发

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python3.3 urlopen