SlideShare a Scribd company logo
2
Most read
Enabling Your Growth Through
www.GlowTouch.com Application Development & Support Services
Python Cheat Sheet
Python sys Variables Python List Methods
argv Command line args append(item) pop(position)
builtin_module_names Linekd C modules count(item) remove(item)
byteorder Native byte order extend(list) reverse()
check_interval Signal check frequency index(item) sort()
exec_prefix Root directory insert(position, item)
executable Name of executable
exitfunc Exit function name Python String Methods
modules Loaded modules capitalize() * lstrip()
path Search path center(width) partition(sep)
platform Current platform count(sub, start, end) replace(old, new)
stdin, stdout, stderr File objects for I/O decode() rfind(sub, start ,end)
version_info Python version info encode() rindex(sub, start, end)
winver Version number endswith(sub) rjust(width)
expandtabs() rpartition(sep)
Python sys.argv find(sub, start, end) rsplit(sep)
sys.argv[0] foo.py index(sub, start, end) rstrip()
sys.argv[1] bar isalnum() * split(sep)
sys.argv[2] -c isalpha() * splitlines()
sys.argv[3] qux isdigit() * startswith(sub)
sys.argv[4] --h islower() * strip()
sys.argv for the command: isspace() * swapcase() *
$ python foo.py bar -c qux --h istitle() * title() *
isupper() * translate(table)
Python os Variables join() upper() *
altsep Alternative sep ljust(width) zfill(width)
curdir Current dir string lower() *
defpath Default search path Methods marked * are locale dependant for
devnull Path of null device 8-bit strings.
extsep Extension separator
linesep Line separator Python File Methods
name Name of OS close() readlines(size)
pardir Parent dir string flush() seek(offset)
pathsep Patch separator fileno() tell()
sep Path separator isatty() truncate(size)
Registered OS names: "posix", "nt", next() write(string)
"mac", "os2", "ce", "java", "riscos" read(size) writelines(list)
readline(size)
Enabling Your Growth Through
www.GlowTouch.com Application Development & Support Services
Python Cheat Sheet
Python Class Special Methods Python Date Formatting
__new__(cls) __lt__(self, other) %a Abbreviated weekday (Sun)
__init__(self, args) __le__(self, other) %A Weekday (Sunday)
__del__(self) __gt__(self, other) %b Abbreviated month name (Jan)
__repr__(self) __ge__(self, other) %B Month name (January)
__str__(self) __eq__(self, other) %c Date and time
__cmp__(self, other) __ne__(self, other) %d Day (leading zeros) (01 to 31)
__index__(self) __nonzero__(self) %H 24 hour (leading zeros) (00 to 23)
__hash__(self) %I 12 hour (leading zeros) (01 to 12)
__getattr__(self, name) %j Day of year (001 to 366)
__getattribute__(self, name) %m Month (01 to 12)
__setattr__(self, name, attr) %M Minute (00 to 59)
__delattr__(self, name) %p AM or PM
__call__(self, args, kwargs) %S Second (00 to 61⁴)
%U Week number¹ (00 to 53)
Python Indexes and Slices %w Weekday² (0 to 6)
len(a) 6 %W Week number³ (00 to 53)
a[0] 0 %x Date
a[5] 5 %X Time
a[-1] 5 %y Year without century (00 to 99)
a[-2] 4 %Y Year (2008)
a[1:] [1,2,3,4,5] %Z Time zone (GMT)
a[:5] [0,1,2,3,4] %% A literal "%" character (%)
a[:-2] [0,1,2,3] ¹ Sunday as start of week. All days in a new
a[1:3] [1,2] year preceding the first Sunday are
a[1:-1] [1,2,3,4] considered to be in week 0.
b=a[:] Shallow copy of a ² 0 is Sunday, 6 is Saturday.
Indexes and Slices of a=[0,1,2,3,4,5] ³ Monday as start of week. All days in a new
year preceding the first Monday are
Python Datetime Methods considered to be in week 0.
today() fromordinal(ordinal) ⁴ This is not a mistake. Range takes account
now(timezoneinfo) combine(date, time) of leap and double-leap seconds.
utcnow() strptime(date, format)
fromtimestamp(timestamp)
utcfromtimestamp(timestamp)
Python Time Methods
replace() utcoffset()
isoformat() dst()
__str__() tzname()
strftime(format)

More Related Content

PDF
Python Variable Types, List, Tuple, Dictionary
PPTX
Python Lambda Function
PDF
Operating system concepts 5th edition by silberschatz & galvin
 
ODP
Python Modules
PDF
Learn 90% of Python in 90 Minutes
PDF
Namespaces
PPT
PHP POWERPOINT SLIDES
PDF
Introduction to Pandas and Time Series Analysis [PyCon DE]
Python Variable Types, List, Tuple, Dictionary
Python Lambda Function
Operating system concepts 5th edition by silberschatz & galvin
 
Python Modules
Learn 90% of Python in 90 Minutes
Namespaces
PHP POWERPOINT SLIDES
Introduction to Pandas and Time Series Analysis [PyCon DE]

What's hot (20)

PPTX
Packages In Python Tutorial
PDF
Python Collections Tutorial | Edureka
PPTX
Python advance
PPTX
Python dictionary
PPTX
Basic array in c programming
PPTX
Unit Testing with Python
PPTX
Merge sort algorithm power point presentation
PDF
A Basic Django Introduction
PDF
pandas - Python Data Analysis
PPT
Collection Framework in java
PPTX
Python Programming Essentials - M8 - String Methods
PPTX
Python Functions
PDF
Python programming : Strings
PPT
Generics in java
PDF
What is Python Lambda Function? Python Tutorial | Edureka
PPTX
Subset sum problem Dynamic and Brute Force Approch
PDF
Regular expression
PDF
Functions and modules in python
PPTX
Spring jdbc
Packages In Python Tutorial
Python Collections Tutorial | Edureka
Python advance
Python dictionary
Basic array in c programming
Unit Testing with Python
Merge sort algorithm power point presentation
A Basic Django Introduction
pandas - Python Data Analysis
Collection Framework in java
Python Programming Essentials - M8 - String Methods
Python Functions
Python programming : Strings
Generics in java
What is Python Lambda Function? Python Tutorial | Edureka
Subset sum problem Dynamic and Brute Force Approch
Regular expression
Functions and modules in python
Spring jdbc
Ad

Viewers also liked (20)

PDF
Python3 cheatsheet
PDF
PDF
Cheat sheets for data scientists
PDF
Vi Cheat Sheet v 1 00
PDF
Advanced R cheat sheet
PDF
Linux cheat-sheet
PDF
R Reference Card for Data Mining
PDF
Unix Command-Line Cheat Sheet BTI2014
PDF
Regression and Classification with R
PDF
Statistics for data scientists
PPTX
Analyze this
PDF
Analyzing mlb data with ggplot
PDF
Table of Useful R commands.
PDF
Ggplot in python
PDF
Using R for Social Media and Sports Analytics
PDF
Hadley verse
PDF
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)
PDF
Python at yhat (august 2013)
PPTX
What is r in spanish.
PDF
Kush stats alpha
Python3 cheatsheet
Cheat sheets for data scientists
Vi Cheat Sheet v 1 00
Advanced R cheat sheet
Linux cheat-sheet
R Reference Card for Data Mining
Unix Command-Line Cheat Sheet BTI2014
Regression and Classification with R
Statistics for data scientists
Analyze this
Analyzing mlb data with ggplot
Table of Useful R commands.
Ggplot in python
Using R for Social Media and Sports Analytics
Hadley verse
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)
Python at yhat (august 2013)
What is r in spanish.
Kush stats alpha
Ad

Similar to Python Cheat Sheet (20)

PDF
PHP Cheat Sheet
PDF
python-cheat-sheet-v1
PPTX
Getting started cpp full
PPTX
Java arrays
PDF
ANSI C REFERENCE CARD
PPTX
20.1 Java working with abstraction
PPTX
R1-Intro (2udsjhfkjdshfkjsdkfhsdkfsfsffs
PPTX
Python 내장 함수
PDF
Benchy, python framework for performance benchmarking of Python Scripts
PPTX
Super Advanced Python –act1
PPSX
DIWE - Advanced PHP Concepts
PPTX
Input output functions
PDF
The best every notes on c language is here check it out
PPTX
ภาษาซีพื้นฐาน
PDF
Programming Fundamentals Arrays and Strings
PPT
TechTalk - Dotnet
PDF
Arrays and function basic c programming notes
PPT
Object Orientation vs. Functional Programming in Python
PPT
Intro to tsql unit 10
PHP Cheat Sheet
python-cheat-sheet-v1
Getting started cpp full
Java arrays
ANSI C REFERENCE CARD
20.1 Java working with abstraction
R1-Intro (2udsjhfkjdshfkjsdkfhsdkfsfsffs
Python 내장 함수
Benchy, python framework for performance benchmarking of Python Scripts
Super Advanced Python –act1
DIWE - Advanced PHP Concepts
Input output functions
The best every notes on c language is here check it out
ภาษาซีพื้นฐาน
Programming Fundamentals Arrays and Strings
TechTalk - Dotnet
Arrays and function basic c programming notes
Object Orientation vs. Functional Programming in Python
Intro to tsql unit 10

More from GlowTouch (12)

PPTX
15 Customer Experience Facts and Stats
PPTX
50,000 More School Children Will Have Food to Eat
PPTX
Josh Annual Day Celebration
PDF
Cloud Application Marketplace Overview
PDF
Swift Reference Guide
PDF
C# Reference Guide
PDF
Java Reference Guide
PDF
PHP Reference Guide
PDF
Java Cheat Sheet
PDF
C# Cheat Sheet
PPTX
GlowTouch Company Overview
PPTX
Overview of Coding Languages
15 Customer Experience Facts and Stats
50,000 More School Children Will Have Food to Eat
Josh Annual Day Celebration
Cloud Application Marketplace Overview
Swift Reference Guide
C# Reference Guide
Java Reference Guide
PHP Reference Guide
Java Cheat Sheet
C# Cheat Sheet
GlowTouch Company Overview
Overview of Coding Languages

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Big Data Technologies - Introduction.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
KodekX | Application Modernization Development
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
cuic standard and advanced reporting.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Network Security Unit 5.pdf for BCA BBA.
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Chapter 3 Spatial Domain Image Processing.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
Reach Out and Touch Someone: Haptics and Empathic Computing
Big Data Technologies - Introduction.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Unlocking AI with Model Context Protocol (MCP)
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Understanding_Digital_Forensics_Presentation.pptx
Review of recent advances in non-invasive hemoglobin estimation
KodekX | Application Modernization Development
The Rise and Fall of 3GPP – Time for a Sabbatical?
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Python Cheat Sheet

  • 1. Enabling Your Growth Through www.GlowTouch.com Application Development & Support Services Python Cheat Sheet Python sys Variables Python List Methods argv Command line args append(item) pop(position) builtin_module_names Linekd C modules count(item) remove(item) byteorder Native byte order extend(list) reverse() check_interval Signal check frequency index(item) sort() exec_prefix Root directory insert(position, item) executable Name of executable exitfunc Exit function name Python String Methods modules Loaded modules capitalize() * lstrip() path Search path center(width) partition(sep) platform Current platform count(sub, start, end) replace(old, new) stdin, stdout, stderr File objects for I/O decode() rfind(sub, start ,end) version_info Python version info encode() rindex(sub, start, end) winver Version number endswith(sub) rjust(width) expandtabs() rpartition(sep) Python sys.argv find(sub, start, end) rsplit(sep) sys.argv[0] foo.py index(sub, start, end) rstrip() sys.argv[1] bar isalnum() * split(sep) sys.argv[2] -c isalpha() * splitlines() sys.argv[3] qux isdigit() * startswith(sub) sys.argv[4] --h islower() * strip() sys.argv for the command: isspace() * swapcase() * $ python foo.py bar -c qux --h istitle() * title() * isupper() * translate(table) Python os Variables join() upper() * altsep Alternative sep ljust(width) zfill(width) curdir Current dir string lower() * defpath Default search path Methods marked * are locale dependant for devnull Path of null device 8-bit strings. extsep Extension separator linesep Line separator Python File Methods name Name of OS close() readlines(size) pardir Parent dir string flush() seek(offset) pathsep Patch separator fileno() tell() sep Path separator isatty() truncate(size) Registered OS names: "posix", "nt", next() write(string) "mac", "os2", "ce", "java", "riscos" read(size) writelines(list) readline(size)
  • 2. Enabling Your Growth Through www.GlowTouch.com Application Development & Support Services Python Cheat Sheet Python Class Special Methods Python Date Formatting __new__(cls) __lt__(self, other) %a Abbreviated weekday (Sun) __init__(self, args) __le__(self, other) %A Weekday (Sunday) __del__(self) __gt__(self, other) %b Abbreviated month name (Jan) __repr__(self) __ge__(self, other) %B Month name (January) __str__(self) __eq__(self, other) %c Date and time __cmp__(self, other) __ne__(self, other) %d Day (leading zeros) (01 to 31) __index__(self) __nonzero__(self) %H 24 hour (leading zeros) (00 to 23) __hash__(self) %I 12 hour (leading zeros) (01 to 12) __getattr__(self, name) %j Day of year (001 to 366) __getattribute__(self, name) %m Month (01 to 12) __setattr__(self, name, attr) %M Minute (00 to 59) __delattr__(self, name) %p AM or PM __call__(self, args, kwargs) %S Second (00 to 61⁴) %U Week number¹ (00 to 53) Python Indexes and Slices %w Weekday² (0 to 6) len(a) 6 %W Week number³ (00 to 53) a[0] 0 %x Date a[5] 5 %X Time a[-1] 5 %y Year without century (00 to 99) a[-2] 4 %Y Year (2008) a[1:] [1,2,3,4,5] %Z Time zone (GMT) a[:5] [0,1,2,3,4] %% A literal "%" character (%) a[:-2] [0,1,2,3] ¹ Sunday as start of week. All days in a new a[1:3] [1,2] year preceding the first Sunday are a[1:-1] [1,2,3,4] considered to be in week 0. b=a[:] Shallow copy of a ² 0 is Sunday, 6 is Saturday. Indexes and Slices of a=[0,1,2,3,4,5] ³ Monday as start of week. All days in a new year preceding the first Monday are Python Datetime Methods considered to be in week 0. today() fromordinal(ordinal) ⁴ This is not a mistake. Range takes account now(timezoneinfo) combine(date, time) of leap and double-leap seconds. utcnow() strptime(date, format) fromtimestamp(timestamp) utcfromtimestamp(timestamp) Python Time Methods replace() utcoffset() isoformat() dst() __str__() tzname() strftime(format)