python一些东西

assert repr() 

 

 1 >>> a
 2 ['d', 'c', 'c', 'f', 'a', 'a', 'b', 'c', 'd']
 3 >>> sorted(a)
 4 ['a', 'a', 'b', 'c', 'c', 'c', 'd', 'd', 'f']
 5 >>> from collections import Counter
 6 >>> a_counter = Counter(a)
 7 >>> a_counter
 8 Counter({'c': 3, 'd': 2, 'a': 2, 'f': 1, 'b': 1})
 9 >>> a_counter.update(["d","d"])
10 >>> a_counter
11 Counter({'d': 4, 'c': 3, 'a': 2, 'f': 1, 'b': 1})
12 >>> type(a_counter)
13 <class 'collections.Counter'>
14 >>> a_counter.most_common(3)
15 [('d', 4), ('c', 3), ('a', 2)]

 

1 #round() 方法返回浮点数x的四舍五入值。
2 
3 round(70.23456) :  70
4 round(56.659,1) :  56.7
5 round(80.264, 2) :  80.26
6 round(100.000056, 3) :  100.0
7 round(-100.000056, 3) :  -100.0

 

posted on 2018-04-18 00:01  NothingLZ  阅读(141)  评论(0编辑  收藏  举报

导航