色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術(shù)文章
文章詳情頁

python 窮舉指定長度的密碼例子

瀏覽:2日期:2022-07-31 13:14:12

本程序可根據(jù)給定的字符字典,窮舉指定長度的所有字符串:

def get_pwd(str, num): if(num == 1): for x in str: yield x else: for x in str: for y in get_pwd(str, num-1): yield x+y strKey='abc'for x in get_pwd(strKey,3): print x

結(jié)果:

aaaaabaacabaabbabcacaacbaccbaababbacbbabbbbbcbcabcbbcccaacabcaccbacbbcbcccaccbccc

本程序占用內(nèi)存小,生成速度快,歡迎嘗試!!!

補(bǔ)充知識:Python 窮舉法, 二分法 與牛頓-拉夫遜方法求解平方根的性能對比

窮舉法, 二分法 與牛頓-拉夫遜方法求解平方根的優(yōu)劣,從左到右依次遞優(yōu)。

經(jīng)過測試,窮舉法基本超過 1 分鐘,還沒有出數(shù)據(jù);

二分法只要區(qū)區(qū)1秒不到就出結(jié)果了。

牛頓-拉夫遜是秒出,沒有任何的停頓。

numberTarget =int(input('Please enter a number:'))numberSqureRoot = 0while(numberSqureRoot<abs(numberTarget)): if numberSqureRoot**2 >= abs(numberTarget): break numberSqureRoot = numberSqureRoot + 1if numberSqureRoot**2 != numberTarget: print('Your number %s is not a perfect squre, the square root is %s ' % ( numberTarget,numberSqureRoot) )else: if numberTarget < 0 : numberSqureRoot = -numberSqureRoot print('Your number %s is a perfect squre, the square root is %s ' % ( numberTarget, numberSqureRoot))print('now we begin to calculate the binary search...')numberTarget=int(input('Please enter the number for binary search...'))numberSqureRoot = 0lowValue = 0.0highValue=numberTarget*1.0epsilon = 0.01numberSqureRoot = (highValue + lowValue)/2while abs(numberSqureRoot**2 - numberTarget) >=epsilon: print('lowValue:%s, highValue:%s, currentValue:%s'%(lowValue,highValue,numberSqureRoot)) if numberSqureRoot**2<numberTarget: lowValue=numberSqureRoot else: highValue=numberSqureRoot numberSqureRoot = (lowValue+highValue) /2print('The number %s has the squre root as %s ' %(numberTarget,numberSqureRoot))print('now we begin to calculate the newTon search...')numberTarget=int(input('Please enter the number for newTon search...'))numberSqureRoot = 0epsilon = 0.01k=numberTargetnumberSqureRoot = k/2.0while( abs(numberSqureRoot*numberSqureRoot - k)>=epsilon): numberSqureRoot=numberSqureRoot-(((numberSqureRoot**2) - k)/(2*numberSqureRoot))print('squre root of %s is %s ' %(numberTarget,numberSqureRoot))

以上這篇python 窮舉指定長度的密碼例子就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 韩国欧美一级毛片 | 欧美aaaaaaaa| 久久亚洲一级毛片 | 2020久久国产最新免费观看 | 日韩视频精品在线 | 久草网在线 | 成人爽a毛片在线视频网站 成人爽爽大片在线观看 | 成人在线第一页 | 俄罗斯小屁孩cao大人免费 | 最新怡红院全部视频在线 | 日韩色网站 | 免费看成人www的网站软件 | 亚洲精品韩国美女在线 | 欧美3p精品三区 | 最近韩国日本免费免费版 | 在线毛片观看 | 国产成年人网站 | 一级特黄特黄毛片欧美的 | 国产成人精品免费久久久久 | 日本无玛 | 国产99视频精品免视看9 | 中文字幕亚洲综合久久男男 | 亚洲精品系列 | aa毛片免费全部播放完整 | 精品国产_亚洲人成在线高清 | 日本a级片免费观看 | 亚洲欧美在线观看视频 | 免费韩国美女爽快一级毛片 | 在线播放亚洲视频 | 成人毛片免费观看视频 | 99精品视频99 | 欧美性色生活免费观看 | 久久精品视频在线观看榴莲视频 | 久久久全国免费视频 | 久久精品视频99 | 精品无码久久久久国产 | 免费看香港一级毛片 | 在线观看精品国产 | 韩国美女一级片 | 美女视频黄在线观看 | 特级aaaaaaaaa毛片免费视频 |