zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    2017.4.18下午
    2017.4.18上午
    2017.4.17上午
    2017.4.14下午
    2017.4.14上午
    4.17下午
    4.17上午
    4.13下午
    4.13上午
    4.10上午
  • 原文地址:https://www.cnblogs.com/luozeng/p/8870916.html
Copyright © 2011-2022 走看看