今天大帅比问我Python生成字典的事情。。想想不能把以前的烂代码丢出去。。百度了一下。。找到了个优雅的写法

看这里看这里:http://www.luwikes.com/archives/117

import itertools
import string

pool = "abcde"

def getstr(maxlen):
    for i in itertools.product(pool,repeat=maxlen):
        line = ''.join(str(x) for x in i)
        print line

if __name__ == '__main__':
    getstr(2)