第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python 內(nèi)聯(lián)語法問題

Python 內(nèi)聯(lián)語法問題

胡子哥哥 2021-09-14 20:34:42
我似乎找不到可以告訴我以下內(nèi)容的有效來源,我正在嘗試了解不同的 Python 技術(shù),誰能解釋這些代碼行,并可能顯示它們的等效內(nèi)容?shortest_path = {initial: (None, 0)}next_destinations = {node: shortest_paths[node] for node in shortest_paths if node not in visited}current_node = min(next_destinations, key=lambda k: next_destinations[k][1])作為參考,一個節(jié)點是一個字符串。
查看完整描述

1 回答

?
躍然一笑

TA貢獻(xiàn)1826條經(jīng)驗 獲得超6個贊

1號線

shortest_path = {initial: (None, 0)}

創(chuàng)建了字典。1 鍵:initial。它的值:(None, 0)這是一個帶有None0(零)的元組。

2號線

next_destinations = {node: shortest_paths[node] for node in shortest_paths if node not in visited}

字典理解。映射nodeshortest_paths[node]. 它for每個都node in shortest_paths做,并且只做if node not in visited

這一行的輸出是一個字典

3號線

current_node = min(next_destinations, key=lambda k: next_destinations[k][1])

嘗試找到最小值并將其分配給current_node。敏什么?上next_destinations。如何知道如何選擇?通過key給出的函數(shù)k,檢查next_destinations[k][1]


查看完整回答
反對 回復(fù) 2021-09-14
  • 1 回答
  • 0 關(guān)注
  • 202 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號