属性错误:';模块';对象没有属性';urlopen';(Python 2.7)

属性错误:';模块';对象没有属性';urlopen';(Python 2.7),python,python-2.7,urllib,Python,Python 2.7,Urllib,我正在为我的学校编写一个程序,我正在为每位老师的文本文件主持每日SBWAT(学生将能够)。这是我的代码SchoolNet.py import Tkinter import urllib print urllib.__file__ def showsbwat(teacher): sbwat = urllib.openurl("192.168.1.203/" + teacher + ".txt") print sbwat def showshecdule(): mainw

我正在为我的学校编写一个程序,我正在为每位老师的文本文件主持每日SBWAT(学生将能够)。这是我的代码SchoolNet.py

import Tkinter
import urllib
print urllib.__file__

def showsbwat(teacher):
    sbwat = urllib.openurl("192.168.1.203/" + teacher + ".txt")
    print sbwat

def showshecdule():
    mainwindow.withdraw()
    schedulewindow.deiconify()
    firstperiodbutton = Tkinter.Button(schedulewindow, text = periodlist[0], command = lambda: showsbwat(periodlist[0]))
    firstperiodbutton.pack()
    global sbwatlabel
    sbwatlabel = Tkinter.Label(schedulewindow, text = "")
    sbwatlabel.pack()

def login():
    try:
        schedulefile = open(usernamevar.get() + ".txt", "r")
        global periodlist
        periodlist = schedulefile.readlines()
        print periodlist
        mainwindow.deiconify()
        loginwindow.withdraw()
    except:
        usernamevar.set("Invalid ID")

loginwindow = Tkinter.Tk()
loginwindow.wm_title('Login to SchoolNet')

mainwindow = Tkinter.Tk()
mainwindow.wm_title('SchoolNet')

schedulewindow = Tkinter.Tk()
schedulewindow.wm_title('SchoolNet Schedule')

mainwindow.withdraw()
schedulewindow.withdraw()
loginwindow.deiconify()

schedulebut = Tkinter.Button(mainwindow, text = 'Schedule', command=showshecdule)
schedulebut.pack()

usernamevar = Tkinter.StringVar()
usernameentry = Tkinter.Entry(loginwindow, textvariable=usernamevar)
usernameentry.pack()

loginbut = Tkinter.Button(loginwindow, text="Login", command=login)
loginbut.pack()

Tkinter.mainloop()
但是,当我运行它时,我不断得到以下错误:

Traceback (most recent call last):
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 1486, in __call__
    return self.func(*args)
  File "SchoolNet.py", line 12, in <lambda>
    firstperiodbutton = Tkinter.Button(schedulewindow, text = periodlist[0], com
mand = lambda: showsbwat(periodlist[0]))
  File "SchoolNet.py", line 6, in showsbwat
    sbwat = urllib.openurl("192.168.1.203/" + teacher + ".txt")
AttributeError: 'module' object has no attribute 'openurl'
回溯(最近一次呼叫最后一次):
文件“C:\Python27\lib\lib tk\Tkinter.py”,第1486行,在uu调用中__
返回self.func(*args)
文件“SchoolNet.py”,第12行,在
firstperiodbutton=Tkinter.Button(schedulewindow,text=periodlist[0],com
mand=lambda:showsbwat(周期列表[0]))
showsbwat中第6行的文件“SchoolNet.py”
sbwat=urllib.openurl(“192.168.1.203/”+teacher+“.txt”)
AttributeError:“模块”对象没有属性“openurl”
我已经用urllib和urllib2尝试过了,但是我得到了相同的错误。目录中的其他文件的名称与任何python模块的名称都不相同。我做错了什么?
我使用的是Python2.7,它是
urlopen
而不是
openurl

 urllib.urlopen()

从urllib.request导入urlopen

URL=“www.webpage-address”

page=urlopen(URL)


text=page.read()

将其更改为
urllib.urlopen()