【问题标题】:Generate all base26 triplests in the fastest way以最快的方式生成所有 base26 三元组
【发布时间】:2013-06-05 21:07:29
【问题描述】:

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

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

在python中最快的方法是什么?

【问题讨论】:

    标签: python algorithm base64 base


    【解决方案1】:
    >>> from itertools import product
    >>> from string import ascii_uppercase
    >>> triplets = map(''.join, product(ascii_uppercase, repeat=3))
    >>> triplets[4]
    'AAE'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-01
      • 1970-01-01
      • 2016-09-23
      • 2011-06-11
      • 1970-01-01
      • 2014-10-22
      • 2010-12-07
      相关资源
      最近更新 更多