Sh4dow's Blog

活了二十几年,从来没有人给过我一次意外感动或惊喜,也没有人在我生日的时候给过我特别的礼物,生病的时候得到的只是一些不在身边的语言安慰,也不见谁真正的照顾过自己,甚至有的时候自己蒙头睡一觉就好了,也有人喜欢过我,但是从没见谁坚持过。

python 生成字典与处理字典脚本

今天写了几个脚本,主要因为自己要做个字典,而又没有什么工具。只能自己写了。写得很垃圾。


1.生成  AAAAbbbb0000      第 一个字母大写。最后一个数字。


import re
import sys    
f=open("dict.txt",'w+')
chars=[
       
         'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','w','x','y','z',
]
chars1=['0','1','2','3','4','5','6','7','8','9']
base=len(chars) #62
end=len(chars)**3
for i in range(0,end):
    n=i
    ch0=chars[n%base]
    n=n/base
    ch1=chars[n%base]
    n=n/base
    ch2=chars1[n%base]
    
    f.write(ch0.upper()+ch0.upper()+ch0.upper()+ch0.upper()+ch1+ch1+ch1+ch1+ch2+ch2+ch2+ch2+'\r\n')
f.close()







2.把txt文件中把第一个字母改成大写


txt1 = open(r"C:\Users\h\Desktop\python\common_pass.dic","r")

totxt = open(r"C:\Users\h\Desktop\python\common_pass_new.dic","w")

for i in txt1.readlines():

    new_line = i.title()

    totxt.write(new_line)

txt1.close()

totxt.close()


3.把txt中长度小于8的全删除。在域里面有规则的话不可能有小于8-12位的




f = open('C:\Users\h\Desktop\python\common_pass_new.dic')
f1 = open('C:\Users\h\Desktop\python\common_pass_new_new.dic','w+')
for j in f.readlines():
    if len(j) > 8:
        f1.write(j)
f1.close()
f.close()



我用的字典是https://shentou.org/xscan.7z  这里的我自己处理一下还有120W还是比较大,看了质量确实不错。




评论

© Sh4dow's Blog | Powered by LOFTER