python 字典操作

假設字典爲dics = {0:'a', 1:'b', 'c':3} 1.從字典中取值,當鍵不存在時不想處理異常 [方法]  dics.get('key', 'not found') [例如]             [解釋] 當鍵'key'不存在是,打印'not found'(即想要處理的信息),當存在是輸出鍵值。 【其他解決方案一】 if key in dics: print
相關文章
相關標籤/搜索