Day 9 Dictionaries , Nesting and the Secret Auction
重點記錄
{Key: Value}
例如:
{"Bug" : "An error in a program that prevents …"
文字用 "" 包起來,
Question 1 : 可以中文嗎?
programming_dictionary = {
"Bug": "An error in a program that prevents the program from running as expected.",
"Function": "A piece of code that you can easily call over and over again."
}
很多個的話, 要用 , "逗號"隔開.
有趣的是, 要列出輸出的某個 key 值, 故意打錯字, 來驗証. 但打錯字, 就當然對不到, 會出現錯字訊息.
Question 2 那真的有打錯字, 那要如何掩蓋其錯誤訊息?
–
字典裡可以包陣列、字典。 // 比較難,需要認真了解邏輯
[{
key: [list],
key2:{Dict},
),
{
key: value,
key2: value,
}]
List是用中括號,Dictionary則是使用大括號。Dictionary是由Key及Value之配對組合而成,順序不重要,但Key的大小寫有分別。跟List一樣,並不限定只能放同一種型態的資料。
與會夥伴的補充:
https://www.one-tab.com/page/BcwJ41dpQumfp0pJamf8Vg