如何使用Python从字母和数字中检查并找到电子邮件地址的最后一个字符?

问题描述 投票:0回答:1

我忘记了我的 Tiktok 帐户的 Gmail 电子邮件地址的最后 3 个字符。如何在Python中编写和检查由A-Z、a-z和0-9字母和数字组成的单个字母和数字?即如何在 python 中使用 A-Z、a-z 和 0-9 字母和数字找到它?

我还有另一个问题。当使用以

import imaplib
import string
开头的Python代码时,是否应该安装
imaplib
string
以及如何安装?

python email numbers character letter
1个回答
0
投票

您可以使用

itertools.product

import itertools
import string

EMAIL_LOCAL_NAME_PREFIX = 'your_email_local_name_prefix'
EMAIL_DOMAIN_NAME = 'gmail.com'
CHARS = string.ascii_letters + string.digits # (A-Z, a-z, 0-9)

for p in itertools.product(CHARS, repeat=3):
    email_local_name_suffix = ''.join(p)
    email = f'{EMAIL_LOCAL_NAME_PREFIX}{email_local_name_suffix}@{EMAIL_DOMAIN_NAME}'
    print(email)

输出:

请注意,有 238328 个电子邮件地址可供检查...

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
...
[email protected]
[email protected]
[email protected]
your_email_local_nam[email protected]
[email protected]

至于你的第二个问题,

imaplib
string
是标准库的一部分,所以你不需要使用像
pip
之类的东西来安装它们。

© www.soinside.com 2019 - 2024. All rights reserved.