SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Downloaden Sie, um offline zu lesen
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)

Weitere ähnliche Inhalte

Was ist angesagt?

Atelier Python 2eme partie par Achraf Kacimi El Hassani
Atelier Python 2eme partie par Achraf Kacimi El HassaniAtelier Python 2eme partie par Achraf Kacimi El Hassani
Atelier Python 2eme partie par Achraf Kacimi El Hassani
Shellmates
 

Was ist angesagt? (20)

How to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaHow to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | Edureka
 
Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 
C++11 & C++14
C++11 & C++14C++11 & C++14
C++11 & C++14
 
Python Programming
Python Programming Python Programming
Python Programming
 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory management
 
CSV JSON and XML files in Python.pptx
CSV JSON and XML files in Python.pptxCSV JSON and XML files in Python.pptx
CSV JSON and XML files in Python.pptx
 
Map, Filter and Reduce In Python
Map, Filter and Reduce In PythonMap, Filter and Reduce In Python
Map, Filter and Reduce In Python
 
Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]
 
Основы MATLAB. Лекция 1.
Основы MATLAB. Лекция 1.Основы MATLAB. Лекция 1.
Основы MATLAB. Лекция 1.
 
Python : Regular expressions
Python : Regular expressionsPython : Regular expressions
Python : Regular expressions
 
Data and time
Data and timeData and time
Data and time
 
PHP
PHPPHP
PHP
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Data annotation validation (ASP.net)
Data annotation validation (ASP.net)Data annotation validation (ASP.net)
Data annotation validation (ASP.net)
 
Python avancé : Interface graphique et programmation évènementielle
Python avancé : Interface graphique et programmation évènementiellePython avancé : Interface graphique et programmation évènementielle
Python avancé : Interface graphique et programmation évènementielle
 
Atelier Python 2eme partie par Achraf Kacimi El Hassani
Atelier Python 2eme partie par Achraf Kacimi El HassaniAtelier Python 2eme partie par Achraf Kacimi El Hassani
Atelier Python 2eme partie par Achraf Kacimi El Hassani
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
 
Python
PythonPython
Python
 

Andere mochten auch

Python
PythonPython
Cheat sheets for data scientists
Cheat sheets for data scientistsCheat sheets for data scientists
Cheat sheets for data scientists
Ajay Ohri
 
Python at yhat (august 2013)
Python at yhat (august 2013)Python at yhat (august 2013)
Python at yhat (august 2013)
Austin Ogilvie
 

Andere mochten auch (20)

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

Ähnlich wie Python Cheat Sheet

Input output functions
Input output functionsInput output functions
Input output functions
hyderali123
 
ภาษาซีพื้นฐาน
ภาษาซีพื้นฐานภาษาซีพื้นฐาน
ภาษาซีพื้นฐาน
Krunee Thitthamon
 
Intro to tsql unit 10
Intro to tsql   unit 10Intro to tsql   unit 10
Intro to tsql unit 10
Syed Asrarali
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
gekiaruj
 

Ähnlich wie Python Cheat Sheet (20)

PHP Cheat Sheet
PHP Cheat SheetPHP Cheat Sheet
PHP Cheat Sheet
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
 
Java arrays
Java    arraysJava    arrays
Java arrays
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARD
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
Python 내장 함수
Python 내장 함수Python 내장 함수
Python 내장 함수
 
Benchy, python framework for performance benchmarking of Python Scripts
Benchy, python framework for performance benchmarking  of Python ScriptsBenchy, python framework for performance benchmarking  of Python Scripts
Benchy, python framework for performance benchmarking of Python Scripts
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
DIWE - Advanced PHP Concepts
DIWE - Advanced PHP ConceptsDIWE - Advanced PHP Concepts
DIWE - Advanced PHP Concepts
 
Input output functions
Input output functionsInput output functions
Input output functions
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
 
ภาษาซีพื้นฐาน
ภาษาซีพื้นฐานภาษาซีพื้นฐาน
ภาษาซีพื้นฐาน
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
 
Object Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in PythonObject Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in Python
 
Intro to tsql unit 10
Intro to tsql   unit 10Intro to tsql   unit 10
Intro to tsql unit 10
 
Java 5 New Feature
Java 5 New FeatureJava 5 New Feature
Java 5 New Feature
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
 

Mehr von GlowTouch

Mehr von GlowTouch (12)

15 Customer Experience Facts and Stats
15 Customer Experience Facts and Stats15 Customer Experience Facts and Stats
15 Customer Experience Facts and Stats
 
50,000 More School Children Will Have Food to Eat
50,000 More School Children Will Have Food to Eat50,000 More School Children Will Have Food to Eat
50,000 More School Children Will Have Food to Eat
 
Josh Annual Day Celebration
Josh Annual Day CelebrationJosh Annual Day Celebration
Josh Annual Day Celebration
 
Cloud Application Marketplace Overview
Cloud Application Marketplace OverviewCloud Application Marketplace Overview
Cloud Application Marketplace Overview
 
Swift Reference Guide
Swift Reference GuideSwift Reference Guide
Swift Reference Guide
 
C# Reference Guide
C# Reference GuideC# Reference Guide
C# Reference Guide
 
Java Reference Guide
Java Reference GuideJava Reference Guide
Java Reference Guide
 
PHP Reference Guide
PHP Reference GuidePHP Reference Guide
PHP Reference Guide
 
Java Cheat Sheet
Java Cheat SheetJava Cheat Sheet
Java Cheat Sheet
 
C# Cheat Sheet
C# Cheat SheetC# Cheat Sheet
C# Cheat Sheet
 
GlowTouch Company Overview
GlowTouch Company OverviewGlowTouch Company Overview
GlowTouch Company Overview
 
Overview of Coding Languages
Overview of Coding LanguagesOverview of Coding Languages
Overview of Coding Languages
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

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)