Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 试图理解交通模拟中的错误_Python_Python 2.7_Debugging_Simulation_Traffic Simulation - Fatal编程技术网

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,还可以将表达式简化为