这让我发疯了。如果我使用此代码:
while msgnums == ['']: # wait until message list from server isn't empty
typ, msgnums = gmail.m.uid('search', None, 'To', new_user)
print '\n', new_user, sec_waiting, typ, msgnums
输出是:
qatestdata+auto20111104113143@gmail.com 300 OK ['']
换句话说,它没有找到我的信息。但是,如果我这样硬编码:
typ, msgnums = gmail.m.uid('search', None, 'To', 'qatestdata+auto20111104113143@gmail.com')
输出是:
qatestdata+auto20111104113844@gmail.com 0 OK ['19']
(它会找到消息。) new_user 是一个字符串。我不明白为什么它不起作用。
我也试过:
search_string = '(To \"' + created_username + '\")'
while msg_uid == ['']: # wait until message list from server isn't empty
resp, msg_uid = gmail.m.search(None, search_string)
但它也失败了。