第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

bool 和 if 語(yǔ)句的問(wèn)題

bool 和 if 語(yǔ)句的問(wèn)題

忽然笑 2021-11-09 19:50:23
我正在構(gòu)建一個(gè) ID Confirm 系統(tǒng),用戶有 3 次嘗試輸入 ID 正確,如果沒有,系統(tǒng)將退出。我的問(wèn)題是當(dāng)用戶最后一次輸入正確的 ID 時(shí),當(dāng)代碼正確時(shí),語(yǔ)句寫出 ID 是正確的,第二行顯示他,他輸入了太多的嘗試和系統(tǒng)正在退出。我該如何修復(fù)這個(gè)錯(cuò)誤?我該如何解決,當(dāng)用戶在 3/3 次嘗試中輸入正確的 ID 時(shí),系統(tǒng)會(huì)說(shuō),正確,我們可以破壞 if 語(yǔ)句。我的代碼:checkas = TrueAttempts = 3CurrentAttemp = 0KickForBadCode = sys.exitwhile checkas:    CurrentAttemp += 1    IDConfirm = input("* [3NEMATIX]: {} Please confirm Your ID CODE... Attempt! {}/{} ".format(Vartotojo_Vardas, CurrentAttemp, Attempts))    with open (DuomenuBaz, mode = 'r', encoding = 'utf-8') as Confirm:        for line in Confirm:            if "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip():                print("Correct!")                Confirm.close()                checkas = False                break            elif "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip() and CurrentAttemp > 2:                clear()                print("Correct!")                Confirm.close()                checkas = False                break            elif CurrentAttemp >2:                clear()                print("~ You have been kicked for too many attempts!")                checkas = False                sys.exit
查看完整描述

2 回答

?
月關(guān)寶盒

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超5個(gè)贊

您exit只需要在CurrentAttempis >than時(shí)才需要Attempts。而如果Vartotojo_Pass是在正確的<=到Attempts。


嘗試更換這部分:


if "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip():

                print("Correct!")

                Confirm.close()

                checkas = False

                break

            elif "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip() and CurrentAttemp > 2:

                clear()

                print("Correct!")

                Confirm.close()

                checkas = False

                break

            elif CurrentAttemp >2:

                clear()

                print("~ You have been kicked for too many attempts!")

                checkas = False

                sys.exit

有了這個(gè):


        if "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip():

            print("Correct!")

            Confirm.close()

            checkas = False

            break

        elif "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip() and CurrentAttemp < Attempts:

            clear()

            print("Correct!")

            Confirm.close()

            checkas = False

            break

        elif CurrentAttemp > Attempts:

            clear()

            print("~ You have been kicked for too many attempts!")

            checkas = False

            sys.exit


查看完整回答
反對(duì) 回復(fù) 2021-11-09
?
慕尼黑5688855

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超2個(gè)贊

我修復(fù)了它,它有太多的 if 語(yǔ)句,導(dǎo)致腳本每次都重新布爾值,并且腳本無(wú)法運(yùn)行。問(wèn)題只是 if 語(yǔ)句。


 checkas = True

    Attempts = 3

    CurrentAttemp = 0

    KickForBadCode = sys.exit

    while checkas:

        CurrentAttemp += 1

        if CurrentAttemp > 3:

            checkas = False

            clear()

            print("~ You have been kicked for too many attempts!")

            sys.exit

        else:

            IDConfirm = input("* [3NEMATIX]: {} Please confirm Your ID CODE... Attempt! {}/{} ".format(Vartotojo_Vardas, CurrentAttemp, Attempts))

            with open (DuomenuBaz, mode = 'r', encoding = 'utf-8') as Confirm:

                for line in Confirm:

                    if "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip():

                        print("Correct!")

                        Confirm.close()

                        checkas = False

                        break

                    else:

                        checkas = True

                        clear()


查看完整回答
反對(duì) 回復(fù) 2021-11-09
  • 2 回答
  • 0 關(guān)注
  • 173 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)