5

我需要生成一个只包含大写英文字母的三元组列表:

["AAA","AAB","AAC", ..., 'ZZZ']

在 python 中执行此操作的最快方法是什么?

4

1 回答 1

5
>>> from itertools import product
>>> from string import ascii_uppercase
>>> triplets = map(''.join, product(ascii_uppercase, repeat=3))
>>> triplets[4]
'AAE'
于 2013-06-10T08:47:33.397 回答