thinkpython2

1) Dictionaries have a method called get that takes a key and a default value.

LookupError is a built-in exception used to indicate that a lookup operation failed.

raise LookupError(‘value does not appear in the dictionary‘)

A dictionary is implemented using a hashtable and that means that the keys have to be     hashable. A hash is a function that takes a value (of any kind) and returns an integer.   Dictionaries use these integers, called hash values, to store and look up key-value     pairs.

时间: 2024-12-25 07:39:08

thinkpython2的相关文章

python 打印 网格

#/usr/bin/python # -*- coding:utf-8 -*- # width 单个网格有多少个 - 宽度# height 单个网格有多少个 | 高度# lateral 横向有多少个网格# vertical 竖向有多少个网格 def printGrid(width,height,lateral,vertical): for i in range(vertical): print_lateral(lateral,width) for n in range(height): prin