當前位置: 首頁>>代碼示例>>Python>>正文


Python Permutation.words方法代碼示例

本文整理匯總了Python中permutation.Permutation.words方法的典型用法代碼示例。如果您正苦於以下問題:Python Permutation.words方法的具體用法?Python Permutation.words怎麽用?Python Permutation.words使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在permutation.Permutation的用法示例。


在下文中一共展示了Permutation.words方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: doGenerate

# 需要導入模塊: from permutation import Permutation [as 別名]
# 或者: from permutation.Permutation import words [as 別名]
def doGenerate():
    variables.head = handleList(variables.head)
    variables.tail = handleList(variables.tail)
    
    variables.name.append("")
    variables.birthday.append("")
    variables.extinfo.append("")
    variables.dict_max.append("")
    variables.tail.append("")
    variables.head.append("")
    variables.year.append("")
#    variables.lett.append("")
    variables.email.append("")
    variables.qq.append("")
    variables.phoneNumer.append("")
    
    f = open('./result.txt', 'w')
    for birstdayItem in variables.birthday:
        for nameItem in variables.name:
            for extinfoItem in variables.extinfo:
                for dictMaxItem in variables.dict_max:
                    for yearItem in variables.year:
                        for phoneItem in variables.phoneNumer:
                            for qqItem in variables.qq:
                                for emailItem in variables.email:
                                    
                                    preS = birstdayItem + nameItem + extinfoItem\
                                     + dictMaxItem + yearItem + phoneItem\
                                      + qqItem + emailItem
                                    if len(preS) < variables.minLen or len(preS) > variables.maxLen:
                                        continue
                                      
                                    obj = Permutation()
                                    obj.words = [birstdayItem, nameItem, extinfoItem, \
                                                 dictMaxItem, \
                                                 yearItem, phoneItem, qqItem, \
                                                 emailItem]
                                    
                                    obj.words = handleList(obj.words)
                                    rst = obj.permutationList()
                                    for s in rst:
                                        if len(s) < variables.minLen or len(s) > variables.maxLen:
                                            break
                                        for tailItem in variables.tail:
                                            for headItem in variables.head:
                                                s2 = headItem + s + tailItem
                                                if len(s2) >= variables.minLen and len(s2) <= variables.maxLen:
                                                    print s2
                                                    if const.isRelease:
                                                        f.write(s2);
                                                        f.write('\n')

    f.close()
    print "Done!"
開發者ID:zgzczzw,項目名稱:dictoryGenerator,代碼行數:56,代碼來源:dicGen.py

示例2: generateBirthDayList

# 需要導入模塊: from permutation import Permutation [as 別名]
# 或者: from permutation.Permutation import words [as 別名]
def generateBirthDayList(yearStr, monthStr, dayStr):
    #以1949-10-01為例
    yearStr = str(yearStr)
    monthStr = "%02d" % (int(monthStr))
    dayStr = "%02d" % (int(dayStr))
    
    birthDayList = []
    birthDayList.append(yearStr)
    birthDayList.append(monthStr)
    birthDayList.append(dayStr)
    
    obj = Permutation()
    obj.words = birthDayList
    variables.birthday.extend(obj.permutationList())
    
    #隻有月份和日期的全序列 10-01
    birthDayList.remove(yearStr)
    obj = Permutation()
    obj.words = birthDayList
    variables.birthday.extend(obj.permutationList())
    birthDayList.append(yearStr)
    
    #日期以單位數的全序列 1949-10-1
    if re.match(r"0\d", monthStr) or re.match(r"0\d", dayStr):
        birthDayList.remove(monthStr)
        birthDayList.append(str(int(monthStr)))
        birthDayList.remove(dayStr)
        birthDayList.append(str(int(dayStr)))
        obj.words = birthDayList
        variables.birthday.extend(obj.permutationList())
        
        #日期以單位數,沒有年份的全序列 10-1
        birthDayList.remove(yearStr)
        obj = Permutation()
        obj.words = birthDayList
        variables.birthday.extend(obj.permutationList())
        birthDayList.append(yearStr)
        
    #年份是兩位數的全序列 49-10-1
    if len(yearStr) == 4:
        sYear = yearStr[2:4]
        generateBirthDayList(sYear, monthStr, dayStr)
開發者ID:zgzczzw,項目名稱:dictoryGenerator,代碼行數:44,代碼來源:dicGen.py

示例3: afterGenerateNameList

# 需要導入模塊: from permutation import Permutation [as 別名]
# 或者: from permutation.Permutation import words [as 別名]
def afterGenerateNameList(f, l):
    nameList = []
    nameList.append(f)
    nameList.append(l)
    obj = Permutation()
    obj.words = nameList
    rst = obj.permutationList()
    if rst:
        variables.name.extend(rst)
        #字符串去重
        variables.name = list(set(variables.name))
開發者ID:zgzczzw,項目名稱:dictoryGenerator,代碼行數:13,代碼來源:dicGen.py


注:本文中的permutation.Permutation.words方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。