[英]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.