重复一个函数 while 循环不在 python 结束

repeat a function while loop not end in python

大家好,我在玩我的小项目时遇到了如何重复函数的问题 我试图在 while 循环中调用它自己的函数但是没有用可能使用另一个函数来调用另一个函数来再次调用这个函数

代码如下:

 #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