簡體   English   中英

我如何在飾品 python 中設置密碼和用戶名?

[英]How do i make a password and username in trinket python?

我努力了

def main(): while True: UserName = input ("Enter Username: ") PassWord = input ("Enter Password: ")

    if UserName == Bob and PassWord == rainbow123:
        time.sleep(1)
        print ("Login successful!")
        logged()

    else:
    print ("Password did not match!")

def logged(): time.sleep(1) print ("Welcome to ----")

主要的()

但我不知道為什么它不起作用

有人請幫助

問題是您沒有在“if”語句中將用戶名和密碼定義為字符串。

import time

def main(): 
    while True: 
        UserName = input("Enter Username: ") 
        PassWord = input("Enter Password: ")

        if UserName == "Bob" and PassWord == "rainbow123":
            time.sleep(1)
            print("Login successful!")
            logged()

        else:
            print("Password did not match!")
def logged(): 
    time.sleep(1) 
    print("Welcome to ----")
main()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM