亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

.lower 不適用于我在 pycharm 中的代碼

.lower 不適用于我在 pycharm 中的代碼

拉風的咖菲貓 2023-08-22 17:07:09
我是 python 新手,這是我的代碼,.lower 通??梢怨ぷ?,但這次不行。technical_dict = {        dict : 'stores a key/value pair',        list : 'stores a value at each index',        map : 'see dict',        set : 'stores unordered unique elements'    }    userInput = (input("What term would you like to lookup or type 'exit' to stop:"))    if userInput.lower() not in technical_dict:        print("Term does not exist in technical dictionary")    if userInput.lower()  in technical_dict:        print(technical_dict[userInput.lower()])        while userInput.lower() != "exit":            userInput = input("What term would you like to lookup or type 'exit' to stop:")            if userInput.lower() in technical_dict:        print(technical_dict[userInput.lower()])            if userInput.lower() not in technical_dict:                print("Term does not exist in technical dictionary")                break
查看完整描述

1 回答

?
慕勒3428872

TA貢獻1848條經驗 獲得超6個贊

您創建詞典的方式似乎存在問題。您現在擁有的鍵值不是 string 或 str 類型。這就是為什么您會收到字典沒有屬性“lower”的錯誤。要修復此問題,您需要更改這些值,使其成為字符串類型。嘗試這個:


technical_dict = {

        'dict' : 'stores a key/value pair',

        'list' : 'stores a value at each index',

        'map' : 'see dict',

        'set' : 'stores unordered unique elements'

    }


查看完整回答
反對 回復 2023-08-22
  • 1 回答
  • 0 關注
  • 194 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號