簡體   English   中英

在循環不以python結束時重復一個函數

[英]repeat a function while loop not end in python

嘿伙計們,我正在玩我的小項目,我遇到了關於如何重復一個函數的問題再次調用這個

代碼如下:

 #this function is to check user and pass that was entered by the user using the inputs function

 def chk(u = str(a[0]), p = int(a[1])):
    while u not in sales_man.keys():
    call this function again

如果你想實現一個簡單的登錄,你可以使用經典的無限循環,如:

def check_user(user):
    return user in sales_man.keys()


while True:
    # [...] get username in input

    if check_user(username):
        # [...] ok, check password
    else:
        # [...] wrong user

暫無
暫無

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

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