python-cheatsheet icon indicating copy to clipboard operation
python-cheatsheet copied to clipboard

All-inclusive Python cheatsheet

Python Cheatsheet


This Python Cheatsheet is based on the book Automate the Boring Stuff with Python and many other sources.

Getting Started

Anyone can forget how to make character classes for a regex, slice a list or do a for loop. This Python cheatsheet tries to provide basic reference for beginner and advanced developers, lower the entry barrier for newcomers and help veterans refresh the old tricks.

Table of Content

Cheatsheet Modules
Python Basics Datetime Module
Built-in Functions Itertools Module
Control Flow Json Module
Functions Random Module
Lists and Tuples Os Module
Dictionaries Pathlib Module
Sets
Comprehensions
Manipulating Strings
String Formatting
Regular Expressions
File and directory Paths
Reading and Writing Files
JSON and YAML
Exception Handling
Debugging
Args and Kwargs
Context Manager
__main__
setup.py
Dataclasses
Virtual Environment