我使用Python imaplib.IMAP4
连接到Google电子邮件。除非我使用包含空格字符的邮箱名称使用IMAP4.select()
方法,否则每件事都可以。假设我的邮箱名称是“Gama Sutra”。
当我执行imap.select('[Gmail]/Gama Sutra')
时,它会给我这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imaplib.py", line 682, in select
typ, dat = self._simple_command(name, mailbox)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imaplib.py", line 1133, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imaplib.py", line 964, in _command_complete
raise self.error('%s command error: %s %s' % (name, typ, data))
imaplib.error: SELECT command error: BAD [b'Could not parse command']
我该如何解决这个问题?
答案 0 :(得分:6)
它应该自动执行此操作,但只需用双引号括起您的文件夹名称:
imap.select('"[Gmail]/Gama Sutra"')