1、ASCII 表 ord函数
ord('char')
>>>ord('a')
97
>>> ord('b')
98
char('number')
>>> print chr(48), chr(49), chr(97)
0 1 a
0011 0000 | 060 | 48 | 0x30 | 0 | 字符0 |
0011 0001 | 061 | 49 | 0x31 | 1 | 字符1 |
0100 0001 | 0101 | 65 | 0x41 | A | 大写字母A |
0100 0010 | 0102 | 66 | 0x42 | B | 大写字母B |
0110 0001 | 0141 | 97 | 0x61 | a | 小写字母a |
0110 0010 | 0142 | 98 | 0x62 | b | 小写字母b |
2、Counter 类使用的方法
from collection import Counter
b = Counter('chenkc')
#Counter({'c': 2, 'h': 1, 'e': 1, 'n': 1, 'k': 1})
Counter用于计数,调用它会返回一个key为列表的值,value为该值的具体个数的对象
count.elements()
# 返回count组合中的值 类似于dict.values()
3、Enumerate
s = [6, 2, 9, 4, 5]
for index, value in enumerate(s, 3):
# 索引, 值 数组,从指定索引开始计数
print('%s, %s' % (index, value))
#输出结果:
4, 6
5, 2
6, 9
7, 4
8, 5