6

Python常用内置数据结构和算法

 3 years ago
source link: http://blog.ilibrary.me/2019/07/15/python%E5%B8%B8%E7%94%A8%E5%86%85%E7%BD%AE%E7%AE%97%E6%B3%95
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
欢迎转载,请支持原创,保留原文链接:blog.ilibrary.me

常用数据结构和算法

  1. 字符串转数组: [x for x in “aaxxddbb”], [*“xxxaaabbbeee”]
  2. collections.Counter, 统计词频用. 这个在统计分类里面用的非常多。
  3. collections.deque,It’s pronounced /dɛk/
  4. math.ceil, math.floor, math.round, int(3.0/2)
  5. bisect.bisect_left, bisect.bisect_right
  6. sorted, List.sort()
  7. filter
  8. functools.reduce
  9. apply
  10. translate, maketrans
  11. range
  12. enumerate
  13. dict, set,str
  14. next(generator)
  15. yield, 生成generator
  16. heapq
  17. any, all
  18. 基础运算: //,**, %, 3.5%1.5=0.5
  19. heapq:
扫描二维码分享到微信朋友圈Loading...Please waitqrcode.php?url=%2F2019%2F07%2F15%2Fpython%25E5%25B8%25B8%25E7%2594%25A8%25E5%2586%2585%25E7%25BD%25AE%25E7%25AE%2597%25E6%25B3%2595

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK