我的一个函数中的if语句没有按照我期望的方式进行分支,我无法弄清楚我做错了什么。任何帮助表示赞赏。
def getStockList (dbCursor, **kwargs) :
returnList = {}
pastDue = False
for key in kwargs :
if key == 'past_due' :
pastDue = kwargs[key]
print ('pastDue before if statement =',pastDue)
if pastDue == True :
print ('retrieving past due stocks')
# ... code removed for simplicity
else:
print ('retrieving all stocks')
# ... code removed for simplicity
print ('pastDue at end =',pastDue)
return returnList
输出就是这个......
pastDue before if statement = True
retrieving all stocks
pastDue at end = True