python密码生成器
作者:互联网
class Password(object): """docstring for Combination""" def __init__(self, chas=[chr(j) for j in range(32,127)]): super(Combination, self).__init__() self.chas = chas def straddone(self,string,index=-1): chars_len = len(self.chas) sting_len = len(string) endstr = self.chas[-1]*sting_len if string != endstr: i = self.chas.index(string[index]) if i >= chars_len-1: i = 0 arr = list(string) arr[index] = self.chas[i] string = ''.join(arr) index = index - 1 string = self.straddone(string,index) else: i = i + 1 arr = list(string) arr[index] = self.chas[i] string = ''.join(arr) return string def generate(self,string=[chr(j) for j in range(32,127)]): self.chas = string string_len = len(string) for i in range(string_len): start_string = self.chas[0]*(i+1) end_string = self.chas[-1]*(i+1) while start_string != end_string: print(start_string) start_string = self.straddone(start_string)
标签:index,arr,string,chas,python,self,生成器,len,密码 来源: https://www.cnblogs.com/navysummer/p/12144564.html