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

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

'str'對象沒有屬性'get'-如何告訴python返回的字符串是字典?

'str'對象沒有屬性'get'-如何告訴python返回的字符串是字典?

qq_笑_17 2021-03-12 15:11:03
當(dāng)我嘗試獲取鍵的值時,我得到一個“ str”對象沒有屬性“ get”錯誤,而鍵的值又是字典的名稱。如何告訴python返回的字符串是字典?choices = ['Country','State','Town']chosen = 'Country'country_color = {'Netherlands':'Red','Sweden':'Brown','Ukraine':'Yellow','China':'Pink','Japan':'Black'}state_color = { .... }town_color = { .... }color_data = {'Country': ['col1','country_color'] ,'State': ['col2','state_color'] ,'Town': ['col3','town_color']}    .....color1 = lambda v: country_color.get(v['col1']) # this workscolor2 = lambda v: country_color.get(v[color_data.get(chosen)[0]]) # this too works  color3 = lambda v: color_data.get(chosen)[1].get(v[color_data.get(chosen)[0]]) # but this doesn't work; error - 'str' object has no attribute 'get'    ....
查看完整描述

2 回答

?
人到中年有點甜

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

如果您這樣編碼:

  1. print("Client Name is : {}".format(function).get()) ----錯誤----

  2. 您將收到此錯誤“ str”對象沒有屬性“ get”

  3. print("Client Name is : {}".format(FNEntry.get())) ----固定----


查看完整回答
反對 回復(fù) 2021-03-31
  • 2 回答
  • 0 關(guān)注
  • 427 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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