简体   繁体   English

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

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

hey guys i was playing around with my small project and i hit this problem on how to repeat a function i have tried to call the function it self with in the while loop but did not work maybe use another function to do so like calling another function to call this one again嘿伙计们,我正在玩我的小项目,我遇到了关于如何重复一个函数的问题再次调用这个

code is as follows:代码如下:

 #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

If you're trying to implement a simple login you can use a classic infinite loop like:如果你想实现一个简单的登录,你可以使用经典的无限循环,如:

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