我想知道为什么代码不能识别10/11的字段值在list['10','11']中,以及为什么它会绕过初始if语句
任何可能的解决方案都会非常感激,代码下面还有运行代码后生成的print语句
TableRow = DBSelect.fetchall()
for Field in TableRow:
print(Field, "This is the currently looped ID")
print(EList, "This is the EList")
if Field in EList : # compares each ID against the EList
print(EList, "This is pre- modified EList")
EList.pop([Field]) # removes the ID from EList
print(EList, "This is post- modified EList")
UnavailableE = UnavailableE + 1 #Add to the number of unavailable E
print(UnavailableE, "This is the Unavailable e in the loop")
elif UnavailableE == ECount: # if the UnavailableE is Equal to ECount, then no ID available - runs this output
print("No e available")
else:
print("Not in list")
为进一步参考,以下是由此产生的打印语句:
10这是当前循环的ID
['10','11']这是EList
不在列表中
11这是当前循环的ID
['10','11']这是EList
不在列表中
将strip添加到strip字段的开头和结尾空格
如果
Field
不是字符串(数字?)或字符串"10"
,那么它就不在列表中,因为列表包含字符串"10 "
和"11 "
(注意后面的空格)相关问题 更多 >
编程相关推荐