我知道这个问题已被提出,但我还没有得到解决方案。 我假设这个异常应该继续for循环,但事实并非如此。 花了一些时间试图解决这个问题,但我找不到任何好的解决方案。 知道吗?
for store in CREATE:
#print "Create ticket:"
print '-' * 80
print store.storeNumber, store.date
br.open(OPEN_NEW_CASE_URL)
form = br.select_form("selsite01")
try:
#assert store.internalID
br["site_id"] = [store.internalID]
except AttributeError:
CREATE.remove(store) # if store is not found on the m***** drop down field
print "[WARNING] Store", store.storeNumber ,"not found in the ticket list, could not create."
continue
br.submit()
""" Build ticket from config file """
br.select_form("newcase")
[.... more code ....]
br.open(LOGOUT_URL) # be nice and logout
编辑(解决了问题):
try:
#assert store.internalID
br["site_id"] = [store.internalID]
except AttributeError:
print "[WARNING] Store", store.storeNumber ,"not found in the ticket list, could not create."
continue
br.submit()
答案 0 :(得分:0)
正如Jayanth Koushik指出,在迭代它时从列表中删除项目会导致此错误。