所以我试着做一个东西,制作所有的组合,然后用这个打印出来
import random
import string
def randomString(stringLength=3):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
print(randomString(3)+str(random.randint(10, 99))+(randomString(3)))
但是我不能让它工作。。。 我希望它看起来像这样,所以它可以打印所有的组合。 aaa00aaa aaa00aab aaa00aac aaa00aad
等等
要生成所有可能的字母组合,可以使用
product()
表单itertools
对我来说,看起来你不想得到一个随机整数,相反,你想要的是一个模式之王的递增数。 打印随机整数
请记住,这将仅将0-9打印为一个字符,例如:aaa0aaa而不是aaa00aaa
相关问题 更多 >
编程相关推荐