|
发表于 2023-5-7 00:11:46
|
显示全部楼层
抱歉,我的错误。在此处, l2 应该是一个字符,而不是一个字符列表。我们需要从列表中选择一个字符。下面是修复后的代码:
- import itertools
- # 定义候选字符
- letters1 = [['Q', 'q'], ['t', 'T', 'y', 'Y']]
- letters2 = [['P', 'T', 'Y'], ['p', 't', 'y']]
- numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
- # 获取所有数字不重复的排列
- number_combinations = list(itertools.permutations(numbers, 5))
- # 遍历所有可能字母组合
- for upper_Q in [True, False]:
- l1 = letters1[0][0] if upper_Q else letters1[0][1]
- l3_options = letters1[1][:2] if upper_Q else letters1[1][2:]
-
- for l3 in l3_options:
- l2_options = letters2[0] if upper_Q else letters2[1]
- for l2 in l2_options:
- # 对每一个数字组合进行测试
- for num_comb in number_combinations:
- result = l1 + num_comb[0] + num_comb[1] + l2 + num_comb[2] + num_comb[3] + l3 + num_comb[4]
- print(result)
复制代码
现在代码正确地从 l2_options 中选择一个字符作为 l2 ,并与其余部分连接以生成密码。这个代码应该能正常运行并生成正确的密码组合。 |
|