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

新闻 前端
近日,有一叫Python-cheatsheet项目在Hacker News、Reddit、Github等网站上成功引起了广大程序员的注意。

 [[271606]]

大多数的cheatsheet都是简单的语法规则列表,如果你手头有一份cheatsheet会让你的工作效率大大提升。

近日,有一叫Python-cheatsheet项目在Hacker News、Reddit、Github等网站上成功引起了广大程序员的注意。

Python-cheatsheet是一份超全的Python速查表,最大的特点就是你无需安装和配置,在线就能使用,内容十分全面 

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

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

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

清单的开头就对这份内容进行一个梳理,可以看出内容涵盖:容器、类型、语法、系统、数据、库,以及Advanced Python等。你只要点击相关知识点,就会跳转到相关的详情页,下面以Main和List为例

Main

if __name__ == '__main__':     # Runs main() if file wasn't imported.
    main()

List

<list> = <list>[from_inclusive : to_exclusive : ±step_size]

<list>.append(<el>)            # Or: <list> += [<el>]
<list>.extend(<collection>)    # Or: <list> += <collection>

<list>.sort()
<list>.reverse()
<list> = sorted(<collection>)
<iter> = reversed(<list>)

sum_of_elements  = sum(<collection>)
elementwise_sum  = [sum(pair) for pair in zip(list_a, list_b)]
sorted_by_second = sorted(<collection>, key=lambda el: el[1])
sorted_by_both   = sorted(<collection>, key=lambda el: (el[1], el[0]))
flatter_list     = list(itertools.chain.from_iterable(<list>))
product_of_elems = functools.reduce(lambda out, x: out * x, <collection>)
list_of_chars    = list(<str>)

index = <list>.index(<el>)     # Returns index of first occurrence or raises ValueError.
<list>.insert(index, <el>)     # Inserts item at index and moves the rest to the right.
<el> = <list>.pop([index])     # Removes and returns item at index or from the end.
<list>.remove(<el>)            # Removes first occurrence of item or raises ValueError.
<list>.clear()                 # Removes all items. Also works on dict and set.

整份文档基本都是代码,只有个别内容会添加一些简短的文字说明,对于用法创建者为了减少使用者的负担,只给了最常见的用法,用最简洁的方式给你最需要的用法

如果你不想在线使用该文档,你也可以下载文本,下载地址:https://raw.githubusercontent.com/gto76/python-cheatsheet/master/README.md

项目地址:https://github.com/gto76/python-cheatsheet

责任编辑:张燕妮 来源: 开源最前线
相关推荐

2019-11-25 10:57:39

云计算迁移人工智能

2017-07-12 10:58:31

医疗大数据电子化服务

2021-09-24 09:59:59

复制粘贴PythonPDF

2022-07-15 14:26:36

开源工具IP

2021-09-24 15:00:26

微信PC电脑移动应用

2021-02-08 11:46:17

Python自动化邮件

2024-04-15 00:00:02

OpenAI模型性能

2021-12-15 10:01:06

Python进度条开发

2009-11-28 20:16:04

2009-03-20 21:22:03

虚拟化Vmwareesx

2023-08-11 13:48:34

开发平台

2022-08-30 09:26:24

数字人民币

2012-10-10 13:58:43

云打印打印服务云计算

2015-10-08 15:38:43

开源IBMLinux on Po

2009-11-11 12:55:52

Visual Stud

2022-09-14 10:16:12

MyBatis加密解密

2009-06-12 08:51:43

Unix操作系统终端设置

2020-11-30 15:42:18

SQL

2021-03-16 15:01:31

Python 开发工具

2009-11-13 15:44:39

Visual StudWindows 7
点赞
收藏

51CTO技术栈公众号