This document is a Python cheat sheet that provides summaries of various Python topics including:
- Python sys variables and their uses
- Python class special methods like __init__() and __repr__()
- Common Python list, string, and file methods
- Python indexes and slices syntax
- Python datetime and time formatting codes
- Details on Python os variables and registered OS names
This document is a Python cheat sheet that provides summaries of various Python topics including:
- Python sys variables and their uses
- Python class special methods like __init__() and __repr__()
- Common Python list, string, and file methods
- Python indexes and slices syntax
- Python datetime and time formatting codes
- Details on Python os variables and registered OS names
Python os Variables end) a[:-2] [0,1,2,3] altsep Alternative sep decode() rfind(sub, start ,end) a[1:3] [1,2] curdir Current dir string encode() rindex(sub, start, a[1:-1] [1,2,3,4] defpath Default search path end) b=a[:] Shallow copy of a devnull Path of null device endswith(sub) rjust(width) Indexes and Slices of a=[0,1,2,3,4,5] extsep Extension separator expandtabs() rpartition(sep) linesep Line separator find(sub, start, end) rsplit(sep) Python Datetime Methods name Name of OS index(sub, start, rstrip() today() fromordinal(ordinal) pardir Parent dir string end) now(timezoneinfo) combine(date, time) pathsep Patch separator isalnum() * split(sep) utcnow() strptime(date, format) sep Path separator isalpha() * splitlines() fromtimestamp(timestamp) Registered OS names: "posix", "nt", isdigit() * startswith(sub) utcfromtimestamp(timestamp) "mac", "os2", "ce", "java", "riscos" islower() * strip() isspace() * swapcase() *
By Dave Child (DaveChild) Published 19th October, 2011. Sponsored by ApolloPad.com
cheatography.com/davechild/ Last updated 3rd November, 2020. Everyone has a novel in them. Finish aloneonahill.com Page 1 of 2. Yours! https://apollopad.com Python Cheat Sheet by Dave Child (DaveChild) via cheatography.com/1/cs/19/
%A Weekday (Sunday) %b Abbreviated month name (Jan) %B Month name (January)
%c Date and time
%d Day (leading zeros) (01 to 31) %H 24 hour (leading zeros) (00 to 23) %I 12 hour (leading zeros) (01 to 12) %j Day of year (001 to 366) %m Month (01 to 12) %M Minute (00 to 59) %p AM or PM %S Second (00 to 61⁴) %U Week number¹ (00 to 53) %w Weekday² (0 to 6) %W Week number³ (00 to 53) %x Date %X Time %y Year without century (00 to 99) %Y Year (2008) %Z Time zone (GMT) %% A literal "%" character (%)
¹ Sunday as start of week. All days in a new
year preceding the first Sunday are considered to be in week 0. ² 0 is Sunday, 6 is Saturday. ³ Monday as start of week. All days in a new year preceding the first Monday are considered to be in week 0. ⁴ This is not a mistake. Range takes account of leap and double-leap seconds.
By Dave Child (DaveChild) Published 19th October, 2011. Sponsored by ApolloPad.com
cheatography.com/davechild/ Last updated 3rd November, 2020. Everyone has a novel in them. Finish aloneonahill.com Page 2 of 2. Yours! https://apollopad.com
Instant Download (Ebook) Learning Java: An Introduction to Real-World Programming with Java by Marc Loy, Patrick Niemeyer, Daniel Leuck PDF All Chapters