官术网_书友最值得收藏!

Dictionary details

There are a few key points about dictionaries that you should be aware of:

  • Sequence operations don't work. As previously stated, dictionaries are mappings, not sequences. Because there's no order to dictionary items, functions such as concatenation and slicing don't work.
  • Assigning new indexes adds entries. Keys can be created when making a dictionary (that is, when you initially create the dictionary) or by adding new values to an existing dictionary. The process is similar and the end result is the same.
  • Keys can be anything immutable. The previous examples showed keys as string objects, but any non-mutable object (such as numbers) can be used for a key. Numbers can be used to create a list-like object but without the ordering. Tuples are sometimes used to make compound keys; class instances that are designed not to change can also be used if needed.
主站蜘蛛池模板: 甘南县| 鹤山市| 陵川县| 府谷县| 晴隆县| 桦南县| 孟津县| 华亭县| 虹口区| 武威市| 潜江市| 晋宁县| 扎鲁特旗| 于都县| 凤山县| 庆元县| 长治市| 防城港市| 颍上县| 长武县| 安丘市| 灵寿县| 罗江县| 铁力市| 县级市| 石渠县| 洱源县| 张家港市| 兰州市| 平顺县| 淮南市| 庐江县| 株洲市| 枣阳市| 福海县| 娱乐| 明溪县| 安化县| 和硕县| 澄城县| 禄丰县|