【发布时间】:2021-03-10 19:31:29
【问题描述】:
我想得到一个列表中所有 3 个字母组合的列表,例如:
aaa, aab, aac
它也必须包含数字。 到目前为止我的代码是
letters = list(string.ascii_lowercase)
letters.extend([i+b+a for i in letters for b in letters for a in letters])
但此代码返回的组合少于 3 位,并且没有数字。
【问题讨论】:
-
你已经尝试了什么?
-
@C_Z_ letters = list(string.ascii_lowercase) letters.extend([i+b+a for i in letters for b in letters for a in letters]) 这存储在一个列表中,其中现在还可以,但我希望尽量减少内存的使用。
-
好的,请使用该代码更新您的问题。
-
but with numbers in it too我们怎么知道哪些数字 -
@coderoftheday,我认为他的意思不是数字,而是数字。
标签: python