Python 试图理解交通模拟中的错误
在我的代码中,我有以下行Python 试图理解交通模拟中的错误,python,python-2.7,debugging,simulation,traffic-simulation,Python,Python 2.7,Debugging,Simulation,Traffic Simulation,在我的代码中,我有以下行 56如果(0听起来你会想调试它中断时的参数是什么。 放入一个试块 try: simulacion[m][p]=1 except IndexError: print('simulation broke again with an index error') print('m is: '+str(m)) print('p is: '+str(p)) #possibly more info needed to diagnose th
56如果(0听起来你会想调试它中断时的参数是什么。
放入一个试块
try:
simulacion[m][p]=1
except IndexError:
print('simulation broke again with an index error')
print('m is: '+str(m))
print('p is: '+str(p))
#possibly more info needed to diagnose the error here
请确保对“p”和“m”保持限制,以确保m*p保持在可承受范围内。可能p
是-1313
?p显然是个问题,在尝试索引确认之前打印p的值。如果0,还可以将表达式简化为