2016-08-31 58 views
-3

私はPythonでパスワードチェッカーを作成しました。ここで私が使用しているコードは次のとおりです。Pythonパスワードチェッカーの問題

import easygui as eg 

def pword(): 
    global password 
    global lower 
    global upper 
    global integer 
    password = eg.enterbox(msg="Please enter your password") 
    length = len(password) 
    print(length) 
    lower = sum([int(c.islower()) for c in password]) 
    print(length) 
    upper = sum([int(c.isupper()) for c in password]) 
    print (upper) 
    integer = sum([int(c.isdigit()) for c in password]) 
    print (integer) 

def length(): 
    global password 
    if len(password) < 6: 
     eg.msgbox(msg="Your password is too short, please try again") 
    elif len(password) > 12: 
     eg.msgbox(msg="Your password is too long, please try again") 

def strength(): 
    global lower 
    global upper 
    global integer 
    if (lower) < 1: 
     eg.msgbox(msg="Please use a mixed case password with lower case letters") 
    elif (upper) < 1: 
     eg.msgbox(msg="Please use a mixed case password with UPPER clase letters") 
    elif (integer) < 1: 
     eg.msgbox(msg="Please try adding a number") 
    else: 
     eg.msgbox(msg="Strength Assessed - Your password is ok") 

while True: 
    pword() 
    length() 
    strength() 

answer = eg.choicebox(title="Try again?",msg="Would you like to try again?", choices=("Yes","No")) 
if answer !="Yes": 
    sys.exit() 

私はそれだけで次のメッセージを思い付くモジュールを実行するために行く:

RESTART:C:\ Users \ユーザーPGUSER72 \のAppDataローカル\プログラム\ \ Pythonの\ Python35-32 \ Pythonのパスワード8.py

私はそれだけでRESTART言う再起動すると - 私はUbuntuの14.0上でテスト

あなたのコードが動作するあなたのインデントを、固定シェル

+1

インデントを修正できますか? – Harrison

+1

まず、インデントをクリーンアップし、不要で安全でないグローバルの使用法を修正してください。 –

答えて

0

4 LTS

EDIT:

また、Windows 7の32ビットのpythonでテスト2.7.12 enter image description here

すべてが正常に動作します。あなたはどのようにあなたのスクリプトを実行していますか?

+1

OPがWindowsを使用していることを確かめてください。 – FamousJameous

+0

私はWindows上でテストレポートを追加しました。 – theBugger