社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Stonecutter

Stonecutter 最近创建的主题
Stonecutter 最近回复了
7 年前
回复了 Stonecutter 创建的主题 » 如果返回true,则使用相同的字典值重复python函数

我不确定我是否正确理解你的问题,但是如果你想在一个特定的值上达到真值,你可以通过一个“for”循环来实现:

my_list=[v1, v2, v3]
for i in my_list:
    if i <= crit_value:
        #Here you can call the function
        print('False')
    else:
        print('True')
        # Next line only when you want to quit the loop here
        break

对于本例,只要列表中的值较低或与临界值相同,就将停留在for循环中;如果高于临界值,则将退出循环并打印“true”。


编辑:

由于您的意思是值总是在变化,您可以这样做:

my_list=[v1, v2, v3]
# Now you use indices starting from zero until the number of elements in the list 
for i in range(len(my_list)):
    # I will set the number of maximum trys to 1000, this can be changed
    for j in range(1000):
        if my_list[i] <= crit_value:
            # Here you would need to reload my_list
            print('False')
        else:
            print('True')
            # To give you the actual value
            print(my_list[i])
            break