作者mserway (mserway)
看板Python
標題錯誤訊息的請教
時間Wed Oct 21 16:51:41 2009
大家好,我(新手)這裡有些新問題,請前輩幫忙指導一下,謝謝。
Traceback (most recent call last):
File "region.py", line 740, in <module>
main()
File "region.py", line 733, in main
experiment_normal()
File "region.py", line 677, in experiment_normal
result2 = region(w)
File "region.py", line 309, in region
buckets = baton.trigger_region_balance(correct_node)
File "/home/mikehong/mike1/baton.py", line 1090, in trigger_region_balance
if left_start_node['LeftRoutingTable'][current_round] != None:
IndexError: list index out of range
我對這段訊息的解釋如下:
在 File "/home/mikehong/mike1/baton.py" 出現錯誤!
if left_start_node['LeftRoutingTable'][current_round] != None:
錯誤的訊息為IndexError: list index out of range
可是程式碼我跑過很多個實驗(大部分成功),只有特定data時才會出現這個錯誤訊息,
關於這個錯誤的意思是 left_start_node['LeftRoutingTable'] 太大嗎?
請版上得高手們講解一下,謝謝。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.130.189.34
→ gmp3fs:current_round比l['LRT']大. 超過了list的大小. 10/21 17:07
→ gmp3fs:並不是list太大. 而是你的index value大於list. 10/21 17:09
→ mserway:不好意思我還是有點不懂,我的current_round為個位整數 10/21 17:39
→ mserway:是說數值大於「LRT」的數值嗎? 10/21 17:42
→ iapptt:gmp3fs的意思是 current_round >= len(..['LRT']) 吧 10/21 22:11
→ gmp3fs:current_round >= len(l['LRT'])-1 # list index從0開始算 10/22 02:08
→ gmp3fs:len([1,2]);[1,2][0];[1,2][1];[1,2][2] # 最後一個 [2] 10/22 02:10
→ gmp3fs:要取的index超過了[1,2]這個list. 所以out of range. 10/22 02:11
→ mserway:喔喔!我了解了! 謝謝gm大和ia大的詳細解釋!謝謝 10/22 13:15