所以这是一个wordlist生成器,当我开始使用python时已经建立起来了(从那时起,我已经做了太多的遗憾)而且昨天我躺在坏的时候意识到我怎么能最终修复我的字母发生器,因为我它有很多问题。现在它或多或少完成了,但只有一件事,这让我疯了,看看:
# coding=utf8
# -*- coding: utf8 -*-
# vim: set fileencoding=utf8 :
# This is the number generator, the easy part
def number(length): # Digit generator
passw = 0
length = 10 ** length
for x in range(length):
f.write(str(passw)),
f.write("\n")
passw += 1
# print passw -1
"""Now this is the alphabetical generator. I am using a while loop to iterate
through the dictionary below. Tried it with a for loop first, but I ran into
some problems."""
def alpha(combinations):
durchgang = 0
truepw = ""
key = 0
currentalpha = -1
while key < combinations:
if key == 58:
combinations -= 58
currentalpha += 1
if currentalpha == 58:
currentalpha = 0
key = 0
truepw = letters[currentalpha]
continue
print truepw + letters[key]
# print key
key += 1
"""Now the problem I'm having, is that when I enter "2" as the length
of the password, everything works fine but as soon as I enter "3", I
just get the same again as with "2". Now I know this is because I am
overwriting "truepw" but I am just not sure how to add another "A" and then
"B" etc. before "truepw". The same with a length of "4" etc. I just have a
feeling I would need a million variables to which I always add the "new
truepw"."""
f = open('wordlist.txt', 'w')
length = int(raw_input("Define length of password: "))
combinations = 58 ** length
letters = {
0:"A",
1:"B",
2:"C",
3:"D",
4:"E",
5:"F",
6:"G",
7:"H",
8:"I",
9:"J",
10:"K",
11:"L",
12:"M",
13:"N",
14:"O",
15:"P",
16:"Q",
17:"R",
18:"S",
19:"T",
20:"U",
21:"V",
22:"W",
23:"X",
24:"Y",
25:"Z",
26:"Ä",
27:"Ö",
28:"Ü",
29:"a",
30:"b",
31:"c",
32:"d",
33:"e",
34:"f",
35:"g",
36:"h",
37:"i",
38:"j",
39:"k",
40:"l",
41:"m",
42:"n",
43:"o",
44:"p",
45:"q",
46:"r",
47:"s",
48:"t",
49:"u",
50:"v",
51:"w",
52:"x",
53:"y",
54:"z",
55:"ä",
56:"ö",
57:"ü"
}
# number(length)
alpha(combinations)
希望你们能以某种方式帮助我。