try语句必须有except Exception:
如果没有except Exception:,就会抛出Syntax error "unexpected unindent (tr.py, line 59)" in file D:\aaaa\tr.py at line 59, character 0.之类的错误。将注释取消后,语句正常。
#代码片断
try:
s.connect(host)
s.login(user,password)
s.sendmail(me, mailto, msg.as_string())
s.close()
# except Exception:
# print('ad')
if __name__ == "__main__": #line 59
import sys
app=QtWidgets.QApplication(sys.argv)
ui=Dialog()
ui.show()
sys.exit(app.exec())
Syntax error "unexpected unindent (tr.py, line 59)" in file D:\aaaa\tr.py at line 59, character 0.