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

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.
主站蜘蛛池模板: 宜春市| 南陵县| 道真| 梨树县| 平果县| 尉氏县| 得荣县| 全州县| 宁晋县| 九寨沟县| 肥西县| 十堰市| 海淀区| 邵武市| 龙里县| 定南县| 云梦县| 荥经县| 赤壁市| 石阡县| 淅川县| 乌拉特前旗| 文山县| 江津市| 信阳市| 全南县| 南宫市| 蒙自县| 永修县| 图们市| 天水市| 亳州市| 揭东县| 渭南市| 探索| 庆元县| 峨山| 河北省| 巴林右旗| 南昌市| 吐鲁番市|