4.12 从今天开始是python
point:用setdefault()方法计算字符串中每个字符出现的次数 +漂亮打印
代码:
1 import pprint 2 message='It was a bright cold dayin April,and the clocks were striking thirteen.' 3 count={} 4 for character in message: 5 count.setdefault(character,0) 6 count[character]=count[character]+1 7 pprint.pprint(count)

浙公网安备 33010602011771号