| 1234567891011121314151617181920 |
- # -*- coding: UTF-8 -*-
- print(hash(1))
- print(hash(1.1))
- print(hash('1'))
- print(hash(True))
- print(hash(False))
- print(hash((1,))) #元组
- d1 = {
- 1:'整形', ###key在字典中必须唯一,(hash值唯一)
- 1.1:'float',
- True:'bool', ###hash值为1,这种情况是字典中的key不唯一了。
- (3, ): '元组'
- }
-
- print(d1)
- list7 = ['hello', 'xdc']
- print(list7[True]) #hash值为‘1’,所以索引值是1
|