一种字典的写法。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gamers/article/details/79518583

以下文章,我不知道是不是抄袭你的,我也不知道,我写的是什么意思。


如有人觉得我冒犯了你,请提出来。TKU


# encode = utf-8
# auth:gamers

import itertools
bete = [ "1", "2", "3", "4", "5", "6", "7", "8"]

for leng in range( 1, ( len(bete) + 1)):
# 创建对象(从列表bete中任意选择leng个元素,然后遍历无重复排列组成的对象)
b = itertools.permutations(bete, leng)
bl = list(b) # 将对象b转换成列表。
for le in range( 0, len(bl)): # 遍历列表中的元素
be = bl[le] #取出每个元素
ch = "".join(be) # 合并列表中的字符串。
if len(ch) < 5: # 控制字符串长度
with open( "d: \\ aa.txt", "a+") as f: # 打开文件
print(ch, end= " \n ", file=f) # 写入文件


以上将列表 bete 中的元素无重复的,排列出来。从而输入到文件。

用以暴破字典的生成。




猜你喜欢

转载自blog.csdn.net/gamers/article/details/79518583