[英]Is there any way in python to repeat a while or for loop by asking the user to do so at the end of the loop?
[英]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.