如何刪除字典中沒有任何值的鍵。我有一個字典爲:刪除具有空白值的鍵
d = {'CB': '', 'CA': [-7.5269999504089355, -2.2330000400543213, 6.748000144958496], 'C': [-8.081000328063965, -3.619999885559082, 6.406000137329102], 'N': [-6.626999855041504, -2.318000078201294, 7.9029998779296875], 'H':''}
我想刪除鍵值爲空。我需要輸出爲:
d = {'CA': [-7.5269999504089355, -2.2330000400543213, 6.748000144958496], 'C': [-8.081000328063965, -3.619999885559082, 6.406000137329102], 'N': [-6.626999855041504, -2.318000078201294, 7.9029998779296875]}
如何做到這一點?
爲什麼是「一條線」的要求?你有哪些困難?確定「空白」值?刪除它們? – Johnsyweb