我想从我的列表中获取7个随机字母,并将其组成一个随机电子邮件,但是我无法打印出完整的电子邮件,只能一次打印出一个字母。
import random
letters = ["a", "b","c", "d","e", "f","g", "h","i", "j","k", "l","m", "n",
"o", "p","q", "r","s", "t","u", "v","w", "x","y", "z",]
random1 = random.choice(letters)
for x in random1(7):
print (x+"@gmail.com")
这只会给我一个错误,如果我修复它,那么我只会收到一个字母的邮件。解决方法是:
random1 = random.choice(letters)
print (random1+"@gmail.com")