Professional Documents
Culture Documents
Python Cheat Sheet v1 PDF
Python Cheat Sheet v1 PDF
String Methods
Datetime Methods
capitalize() *
lstrip()
today()
fromordinal(ordinal)
center(width)
partition(sep)
now(timezoneinfo)
combine(date, time)
byteorder
replace(old, new)
utcnow()
strptime(date, format)
check_interval
decode()
fromtimestamp(timestamp)
utcfromtimestamp(timestamp)
argv
exec_prefix
Root directory
encode()
executable
Name of executable
endswith(sub)
rjust(width)
exitfunc
expandtabs()
rpartition(sep)
modules
Loaded modules
path
Search path
rstrip()
replace()
utcoffset()
platform
Current platform
isalnum() *
split(sep)
isoformat()
dst()
isalpha() *
splitlines()
__str__()
tzname()
version_info
isdigit() *
startswith(sub)
strftime(format)
winver
Version number
islower() *
strip()
isspace() *
swapcase() *
istitle() *
title() *
Time Methods
isupper() *
translate(table)
foo.py
join()
upper() *
%A Weekday (Sunday)
sys.argv[1]
bar
ljust(width)
zfill(width)
sys.argv[2]
-c
lower() *
sys.argv[0]
sys.argv[3]
qux
sys.argv[4]
--h
Note
os Variables
%j
List Methods
altsep
Alternative sep
curdir
append(item)
pop(position)
defpath
count(item)
remove(item)
%p AM or PM
devnull
extend(list)
reverse()
%S Second (00 to 61 4)
extsep
Extension separator
index(item)
sort()
%U Week number
linesep
Line separator
insert(position, item)
name
Name of OS
%W Week number
pardir
%x Date
pathsep
Patch separator
sep
Path separator
Note
%w Weekday
File Methods
(00 to 53)
(0 to 6)
3
(00 to 53)
%X Time
close()
readlines(size)
flush()
seek(offset)
%Y Year (2008)
fileno()
tell()
isatty()
truncate(size)
next()
write(string)
read(size)
writelines(list)
1.
readline(size)
__new__(cls)
__lt__(self, other)
__init__(self, args)
__le__(self, other)
__del__(self)
__gt__(self, other)
__repr__(self)
__ge__(self, other)
len(a)
__str__(self)
2.
0 is Sunday, 6 is Saturday.
3.
__eq__(self, other)
a[0]
a[5]
__index__(self)
a[-1]
__hash__(self)
a[-2]
__getattr__(self, name)
a[1:]
[1,2,3,4,5]
__getattribute__(self, name)
a[:5]
[0,1,2,3,4]
a[:-2]
[0,1,2,3]
seconds.
__delattr__(self, name)
a[1:3]
[1,2]
a[1:-1]
[1,2,3,4]
b=a[:]
Shallow copy of a
__nonzero__(self)
4.