我正在为我的学校写一个程序,并且我每天为每个老师主持sbwat(学生将能够)的文本文件。这是我的密码,学校网.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()
但是,当我运行它时,我总是得到这个错误:
^{pr2}$我用urllib和urllib2尝试过这个方法,但是我得到了相同的错误。目录中的其他文件的名称与任何python模块的名称相同。我做错什么了? 我使用的是python2.7
它是
urlopen
不是openurl
:从urllib.请求导入urlopen
URL=“www.webpage-address““
page=URL打开(URL)
文本=页码:阅读()
相关问题 更多 >
编程相关推荐