如何将这个简单的bruteforce转换成多线程程序

2024-04-23 10:15:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我写了这个简单的程序,让我的字母和数字的组合。但这对于大弦来说是非常慢的。所以我想把它转换成多线程程序。我不是Python专家。有人能告诉我怎么做吗。你知道吗

import string

    def bruteForce(charList,size,nwCombination=[]):
        if not nwCombination:
            nwCombination=charList
        if size==1:
            return nwCombination
        finalCombination=[]
        for x in charList:
            for n in nwCombination:
                cntStr=str(x)+""+str(n)
                finalCombination.append(cntStr)
                if(cntStr=='aadd'):
                    print("string found")
                    print(cntStr)
                    exit(0)
        return bruteForce(charList,size-1,finalCombination)

    allCharlist=string.ascii_lowercase+string.ascii_uppercase
    bruteForce(list(allCharlist)+list(range(0,9)),5)

Tags: in程序forsizestringreturnifprint