我正在尝试让 Tkinter 显示繁忙的光标。不幸的是,我一定错过了一些非常明显的东西。以下是一个非常简单的程序,可以重现我的问题:
from Tkinter import *
import time
def do_something():
print "starting"
window.config(cursor="wait")
time.sleep(5)
window.config(cursor="")
print "done"
return
root = Tk()
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Do Something", command=do_something)
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="File", menu=filemenu)
root.config(menu=menubar)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
我没有看到光标有任何变化
我正在尝试通过office365服务器发送电子邮件.电子邮件已正确发送,但邮件未附加
非常感谢援助
import smtplib
to = "me@gmail.com"
office365_user = 'announcement@somewhere.com'
office365_pwd = 'password'
smtpserver = smtplib.SMTP("smtp.office365.com",587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo()
smtpserver.login(office365_user,office365_pwd)
msg = "This is a test email \n"
smtpserver.sendmail(office365_user, to, msg)
smtpserver.close()
Run Code Online (Sandbox Code Playgroud) 伙计们,
我已经辞职以解决这个问题,但我想检查Python是否真的按预期运行.
在示例中,"sample.txt"是任何读取和解析的多行文本文件.
try:
file=open('sample.txt','r')
for line in file:
(some action here)
except:
print "Couldn't open file"
file.close()
Run Code Online (Sandbox Code Playgroud)
我观察到的动作是打开"sample.txt"并处理第一行,然后逻辑进入"except"子句.
WAD还是这个bug?