在這段代碼中,我無法訪問 while 回圈內的佇列元素。它向我展示
“int”物件不可下標
但是如果我在 while 回圈之外訪問它,那么它作業正常。請給出一個想法,我該如何解決這個問題?
代碼:
queue.put([0,1])
sort_path[1]=0;
a = queue.get()
print(a[0])
while not queue.empty():
N = queue.get()
weight = N[0]
node = N[1]
for i in graph[node]:
if(weight i[1]<sort_path[i[0]]):
sort_path[i[0]]=weight i[1]
queue.put(sort_path[i[0]],sort_path[i[0]])
print(sort_path)

uj5u.com熱心網友回復:
把tuple你在第一行做得好的使用括號
queue.put((sort_path[i[0]], sort_path[i[0]]))
現在關于queue.put你使用第二個引數的檔案block
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/389948.html
上一篇:ZipFile:檢查密碼是否正確
