この例では、参考のために Python でランダムなパスワードを生成する実装プロセスを共有します。具体的な内容は次のとおりです
主に MySQL データベース内の空のパスワードと弱いパスワードを検出するために使用されるプログラムを作成しました。弱いパスワードのタイプは次のように定義されています:
1. get_weak_num で実装される連続数字(123456 など)
2. get_weak_character で実装される連続文字もちろん、数字はランダムです。
3. 数字と文字のランダムな組み合わせ
。 get_weak_num_character で実装されます。同時に、異なるパスワードを保存するために、password_exist のリストが定義されます。新しく生成されたパスワードがリストに存在する場合、MySQL データベースへの接続は実行されず、直接次のサイクルに進みます。
詳細は以下の通りです:#coding=utf8 import random,string,MySQLdb def get_num(): return random.randint(0,9) def get_char(): return random.choice(tuple(string.lowercase)) def choose_any(): return [str(get_num()),get_char()] def get_weak_num(): weak_num=[] initial_num=get_num() for i in range(get_num()): weak_num.append(str(initial_num+i)) if initial_num +i ==9: break; return weak_num def get_weak_character(): weak_character=[] initial_character=get_char() for i in range(get_num()): weak_character.append(chr(ord(initial_character)+i)) if chr(ord(initial_character)+i) == 'z': break return weak_character def get_weak_num_character(): return [random.choice(choose_any()) for num in range(get_num())] password_exist=[] for i in range(10000): choice = [get_weak_num(), get_weak_character(), get_weak_num_character()] password=''.join(random.choice(choice)) print "第"+str(i)+"次密码为:"+password if password in password_exist: continue else: try: MySQLdb.connect('192.168.244.145', 'root', password) print 'The password for MySQL is:'+password break except: continue password_exist.append(password) if i == 9999: print 'The password is not so weak~'以上がこの記事の全内容です、皆様の学習に少しでもお役に立てれば幸いです。 Python がランダムなパスワードを生成する方法に関連するその他の記事については、PHP 中国語 Web サイトに注目してください。

slicingapythonlistisdoneusingtheyntaxlist [start:stop:step] .hore'showitworks:1)startisthe indexofthefirstelementtoinclude.2)spotisthe indexofthefirmenttoeexclude.3)staptistheincrementbetbetinelements

numpyallows forvariousoperationsonarrays:1)basicarithmeticlikeaddition、減算、乗算、および分割; 2)AdvancedperationssuchasmatrixMultiplication;

Arraysinpython、特にnumpyandpandas、aresentialfordataanalysis、offeringspeedandeficiency.1)numpyarraysenable numpyarraysenable handling forlaredatasents andcomplexoperationslikemoverages.2)Pandasextendsnumpy'scapabivitieswithdataframesfortruc

listsandnumpyarraysinpythonhavedifferentmemoryfootprints:listsaremoreflexiblellessmemory-efficient、whileenumpyarraysaraysareoptimizedfornumericaldata.1)listsstorereferencesto objects、with whowedaround64byteson64-bitedatigu

toensurepythonscriptsbehaveCorrectlyAcrossDevelosment、staging、and Production、usetheseStrategies:1)環境variablesforsimplestetings、2)configurationfilesforcomplexsetups、and3)dynamicloadingforadaptability.eachtododododododofersuniquebentandrequiresca

Pythonリストスライスの基本的な構文はリストです[start:stop:step]。 1.STARTは最初の要素インデックス、2。ストップは除外された最初の要素インデックスであり、3.ステップは要素間のステップサイズを決定します。スライスは、データを抽出するためだけでなく、リストを変更および反転させるためにも使用されます。

ListSoutPerformArraysIn:1)ダイナミシジョンアンドフレーケンティオン/削除、2)ストーリングヘテロゼンダタ、および3)メモリ効率の装飾、ButmayhaveslightPerformancostsinceNASOPERATIONS。

toconvertapythonarraytoalist、usetheList()constructororageneratorexpression.1)importhearraymoduleandcreateanarray.2)useList(arr)または[xforxinarr] toconvertoalistは、largedatatessを変えることを伴うものです。


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

SecLists
SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。

SublimeText3 中国語版
中国語版、とても使いやすい

Dreamweaver Mac版
ビジュアル Web 開発ツール

ホットトピック









