l  A simple dictionary

The window will show green.

l  Using dictionary

n  Add key-value pair

For example,

The window will show

    • Modify the key-value pair

    • Delete the key-value pair

Use del is OK.

For example,

Dictionary will not include points.

    • Dictionary just like struct in C language.

    • The dictionary which consists of many objects:

For example,

It will show,

Remember the format!

l  Ergodic dictionary

n  Ergodic all key-value pairs

Method: items(): items()方法用于返回字典dict的(key,value)元组对的列表

    • Ergodic all keys

Method: keys():返回字典dict的键列表

For example,

They all have same output.

n  Ergodic all values

n  Method: values():返回字典dict的值列表

As we all know, the list of value may have same values, then ,how to keep only one value?

We can use set(). For example,

n  Nesting: 将一系列字典存储在列表中,或将列表作为值存储在字典中,这被称为嵌套。