简体   繁体   English

为什么我一直得到相同的输出?

[英]Why do I keep getting the same outputs?

I am creating a for loop and I keep getting the output twice:我正在创建一个 for 循环,并且不断获得 output 两次:

    totalelements = len(uniquevalueslist)
    for id in [23, 45, 76]:
        if id not in uniquevaluelist:
            stmt = f"""INSERT INTO..."""
            for x in range(totalelements):
                stmt = stmt + f" SELECT...."
                if x < totalelements-1:
                    stmt = stmt + "UNION ALL " 
                else:
                    stmt += stmt   

my output is that I get the INSERT INTO Statement Twice我的 output 是我两次获得 INSERT INTO 语句

the if statement is inside the for loop. if语句位于for循环内。 this means it will be evaluated each time you loop through the items.这意味着每次遍历项目时都会对其进行评估。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我会为同一个数据集得到不同的输出? - Why am I getting different outputs for the same dataset? 为什么对于(看似)相同的代码我得到不同的输出? - Why am I getting different outputs for the (seemingly) same code? 为什么我不断收到中断错误? 我对继续和通过有同样的问题 - Why do i keep getting break error? I have the same problem with continue and pass 为什么我总是收到这两个错误? - Why do I keep getting these two errors? 为什么我不断收到此错误消息? - Why do i keep getting this error message? 为什么我不断收到对象错误? - Why do I keep getting object errors? 为什么我不断得到“x 和 y 必须具有相同的第一维,但具有形状 (100,) 和 (1, 100)”? - Why do I keep on getting “x and y must have same first dimension, but have shapes (100,) and (1, 100)”? 为什么我不断收到此错误以及如何解决它 - why do i keep getting this error and how do i solve it 为什么我在这个 window 中不断收到“无效语法”错误? 但是当我在 VS Code 中运行相同的代码时它可以工作 - Why do I keep getting "Invalid Syntax" error with this code in this window? But when I run the same code in VS Code It works 为什么我使用 Python function 和 Numpy 内置点() Python function 得到 2 个不同的输出 - Why I am getting 2 different outputs for same calculation using Python function and Numpy inbuilt dot() function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM