[英]How can you generate a list containing a mix of consecutive numbers and letters?
How would I go about generating the full list of possible iterations from at A1 AAA to Y999YYY?我将如何 go 生成从 A1 AAA 到 Y999YYY 的可能迭代的完整列表? Would such as list be a struggle for my computer processor to generate?
我的计算机处理器生成这样的列表会很困难吗? What type of file would be the best to save such a list in order to be searched later?
什么类型的文件最适合保存这样的列表以便以后搜索?
You should check out the package itertools
.您应该查看 package
itertools
。 It is awesome for generating combinations/permutations of anything.生成任何东西的组合/排列都很棒。
import itertools
a = list(itertools.permutations([1,2,"A","B"])))
print(a)
The example mixes all of the numbers and letters together (I'm not totally clear on your problem statement).该示例将所有数字和字母混合在一起(我对您的问题陈述并不完全清楚)。 It should be pretty easy to make permutations/combinations of your letters, permutations/combinations of numbers, and mix them together in to the final result if you want them ordered together.
如果您希望将它们排列在一起,那么对您的字母、数字的排列/组合进行排列/组合以及将它们混合在一起形成最终结果应该很容易。
File types?文件类型? That is a personal preference.
这是个人喜好。
.json
would work well because you can save lists of lists of things. .json
会很好用,因为您可以保存事物列表。
import json
my_list = [['a', 'b','c'], ['b', 'a','c']]
with open("my_numbers.json", "w") as fp:
json.dump(my_list, fp)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.