Python: Imaplib error
问题 import serial import imaplib from time import sleep IMAP_SERVER='imap.gmail.com' IMAP_PORT=993 ser= serial.Serial ('/dev/ttyACM0',9600) while True: M = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT) rc, resp = M.login('user@gmail.com', 'Password') print rc, resp M.select() for msg_num in M.search("INBOX", "UNDELETED")[1][0].split(): msg = M.fetch('1', '(BODY.PEEK[TEXT])') try: String = msg[1][0][1][139:148] except TypeError: continue print String if String == "This is just a test...": ser.write('0