我想在Python中使電子郵件客戶端。即時得到以下錯誤:PyQt4如何從QTextEdit和無法創建文本的文本創建消息框
def egonder(self):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
usrnam=self.ad.text()
passwds=self.sifre.text()
if usrnam=="" or passwds=="":
QtGui.QMessageBox.warning("Fill every blank.")
else:
server.login(usrnam,passwds)
self.durum.setText("Logging in...")
mytext=""
self.mesaj.setPlainText(mytext)
msg = self.konu.text(),"\n",mytext
server.sendmail(self.kimden.text(), self.kime.text(), msg)
self.durum.setText("Email sent.")
它給了我以下錯誤:
File "eposta.py", line 105, in egonder
server.sendmail(self.kimden.text(), self.kime.text(), msg)
File "/usr/lib/python3.4/smtplib.py", line 793, in sendmail
(code, resp) = self.data(msg)
File "/usr/lib/python3.4/smtplib.py", line 532, in data
q = _quote_periods(msg)
File "/usr/lib/python3.4/smtplib.py", line 168, in _quote_periods
return re.sub(br'(?m)^\.', b'..', bindata)
File "/usr/lib/python3.4/re.py", line 175, in sub
return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or buffer
,當我嘗試使消息框顯示它給我的錯誤:
QtGui.QMessageBox.warning("Fill every blank.")
TypeError: arguments did not match any overloaded call:
QMessageBox.warning(QWidget, str, str, QMessageBox.StandardButtons buttons=QMessageBox.Ok, QMessageBox.StandardButton defaultButton=QMessageBox.NoButton): argument 1 has unexpected type 'str'
QMessageBox.warning(QWidget, str, str, int, int, int button2=0): argument 1 has unexpected type 'str'
QMessageBox.warning(QWidget, str, str, str, str button1Text='', str button2Text='', int defaultButtonNumber=0, int escapeButtonNumber=-1): argument 1 has unexpected type 'str'
謝謝
非常感謝您! – user3755771
@ user3755771如果已經爲您排序,請接受我的回答。 – Shadow9043
對不起@ Shadow9040不知道我應該這樣做。完成 – user3755771