【发布时间】:2016-03-13 19:16:19
【问题描述】:
我想知道为什么代码没有识别出10 / 11的Field值在列表['10', '11']之内,以及为什么它绕过了最初的if语句。
任何可能的解决方案将不胜感激,在代码下方还有代码运行后产生的打印语句。
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
不在列表中
【问题讨论】: