简体   繁体   中英

Creating permutations of e-mail addresses

I want to make e-mail address generator. Something like mixing the email parts.

I counted and with 4 parts of an email (name, surnames, numbers, dots/special characters) there will be 256 combinations without the host.

With using inter tools I could not add host to out string and that string is not an email, but text like: ('1','2','3',4') , but I want it to be 1234@mail.com .

I'm using Python 3.

I believe this is what you're after

from itertools import permutations

email = '1234@mail.com'
name, sep, domain = email.partition('@')
perm_list = [''.join(x)+sep+domain for x in permutations(name)]

#Output
['1234@mail.com', '1243@mail.com', '1324@mail.com', ... ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM