我正在尝试登录gmail并从python包中读取消息。但是得到错误:[ALERT]请通过网络浏览器登录:https://support.google.com/mail/accounts/answer/78754(失败)
import imaplib
import email
m = imaplib.IMAP4_SSL("imap.gmail.com", 993)
m.login("username@gmail.com","password")
m.select('"[Gmail]/All Mail"')
result, data = m.uid('search', None, "ALL") # search all email and return uids
if result == 'OK':
for num in data[0].split():
result, data = m.uid('fetch', num, '(RFC822)')
if result == 'OK':
email_message = email.message_from_bytes(data[0][1]) # raw email text including headers
print('From:' + email_message['From'])
m.close()
m.logout()
答案 0 :(得分:2)
这对我有用:
{'Name': ['Colin', 'Doyon', 'Tremblay', 'Audry', 'Gamelin', 'Dagenais', 'Legault',
'Larochelle', 'Gagnon', 'Simard'],
'FirstName': ['Jonas', 'Elisabeth', 'Françcois', 'Francine', 'Geneviève',
'Robert', 'Maxime', 'Pierre', 'Emilie', 'Martine'],
'TP01': ['7', '9.5', '8', '5', '6', '8', '10', '3', '7', '8'],
'TP02': ['12', '14', '12', '13', '10', '12', '14', '11', '10', '15'],
'TP03': ['11', '12', '11', '10', '10', '13', '12', '6', '7', '14'],
'EXAMEN_INTRA': ['22', '26', '20', '22', '20', '23', '27', '15', '13', '28'],
'EXAMEN_FINAL': ['28', '20', '22', '15', '14', '22', '25', '14', '14', '27']}
答案 1 :(得分:0)
只需为您的Gmail帐户-https://myaccount.google.com/lesssecureapps
启用此功能即可