7921 Star!Python学习的必备法宝,随查随用,太方便了吧

论坛 期权论坛 期权     
小象   2019-7-27 14:23   3488   0


源 / 开源最前线
大多数的cheatsheet都是简单的语法规则列表,如果你手头有一份cheatsheet会让你的工作效率大大提升。
近日,有一叫Python-cheatsheet项目在Hacker News、Reddit、Github等网站上成功引起了广大程序员的注意。
Python-cheatsheet是一份超全的Python速查表,最大的特点就是你无需安装和配置,在线就能使用,内容十分全面


目前,python-cheatsheet已经过在Github上获得 7885 个Star,1572 个Fork(Github地址:https://github.com/gto76/python-cheatsheet)


清单的开头就对这份内容进行一个梳理,可以看出内容涵盖:容器、类型、语法、系统、数据、库,以及Advanced Python等。你只要点击相关知识点,就会跳转到相关的详情页,下面以Main和List为例
[h1]Main[/h1]
  1. if __name__ == '__main__':     # Runs main() if file wasn't imported.
复制代码
  1.     main()
复制代码
List
  1. = [from_inclusive : to_exclusive : ±step_size]
复制代码
  1. .append()            # Or:  += []
复制代码
  1. .extend()    # Or:  +=
复制代码
  1. .sort()
复制代码
  1. .reverse()
复制代码
  1. = sorted()
复制代码
  1. = reversed()
复制代码
  1. sum_of_elements  = sum()
复制代码
  1. elementwise_sum  = [sum(pair) for pair in zip(list_a, list_b)]
复制代码
  1. sorted_by_second = sorted(, key=lambda el: el[1])
复制代码
  1. sorted_by_both   = sorted(, key=lambda el: (el[1], el[0]))
复制代码
  1. flatter_list     = list(itertools.chain.from_iterable())
复制代码
  1. product_of_elems = functools.reduce(lambda out, x: out * x, )
复制代码
  1. list_of_chars    = list()
复制代码
  1. index = .index()     # Returns index of first occurrence or raises ValueError.
复制代码
  1. .insert(index, )     # Inserts item at index and moves the rest to the right.
复制代码
  1. = .pop([index])     # Removes and returns item at index or from the end.
复制代码
  1. .remove()            # Removes first occurrence of item or raises ValueError.
复制代码
  1. .clear()                 # Removes all items. Also works on dict and set.
复制代码
整份文档基本都是代码,只有个别内容会添加一些简短的文字说明,对于用法创建者为了减少使用者的负担,只给了最常见的用法,用最简洁的方式给你最需要的用法
如果你不想在线使用该文档,你也可以下载文本,下载地址:https://raw.githubusercontent.com/gto76/python-cheatsheet/master/README.md
-END-
转载声明:本文选自「开源最前线」。
重磅推出全新学习模式用打卡学Python每天30分钟30天学会Python编程


世界正在奖励坚持学习的人!
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:29
帖子:11
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP