Python Cheat Sheet | OverAPI.com https://overapi.
com/python
OverAPI.com Python jQuery NodeJS PHP Java Ruby Javascript ActionScript CSS Express More »
Resource String File Set & Date Time Array Math
Online String Methods Methods Mapping Date Object Array Methods Number Theoretic
Official Website capitalize() close() replace((year, month, day)) append(x) ceil(x)
center(width[, fillchar]) flush() Set Types timetuple() buffer_info() copysign(x,y)
Download count(sub[, start[, end]]) fileno() len(s) toordinal() byteswap() fabs(x)
Python Quick Reference Card [. decode isatty() x in s weekday()() count(x) factorial(x)
pdf] encode([encoding[, errors]]) next() isoweekday()() extend(iterable) floor(x)
x not in s
Python 2.6 Quick Reference endswith(suffix[, start[, end]]) read([size]) isocalendar()() fromfile(f,n) fmod(x,y)
isdisjoint(other)
expandtabs([tabsize]) readline([size]) isoformat() fromlist(list) frexp(x)
issubset(others)
Related find(sub[, start[, end]]) readlines([sizehint]) __str__() fromstring(s) fsum(iterable)
issuperset
Django format(*args, **kwargs) xreadlines() ctime() fromunicode(s) isinf(x)
union(other...)
index(sub[, start[, end]]) seek(offset[, whence]) strftime() index(x) isnan(x)
intersection(other, ...)
isalnum() tell() insert(i,x) ldexp(x,i)
difference(other...)
isalpha() truncate([size])
symmetric_difference(other)
Datetime Object pop([i]) modf()
isdigit() write(str) date() remove(x) trunc()
copy()
Random islower()
isspace()
writelines(sequence)
update()
time()
timetz()
reverse()
tofile(f) Power and Logarithmic
intersection_update()
Functions
istitle() Attributes difference_update()
replace([year[, month[, day[, ho tolist() exp(x)
isupper() closed ur[, minute[, second[, microseco tostring() log(x[,base])
seed([x]) symmetric_difference_update()
join(iterable) encoding nd[, tzinfo]]]]]]]]) tounicode() log1p(x)
getstate() add(elem)
ljust(width[, fillchar]) errors astimezone(tz) log10(x)
setstate(state) remove()
jumpahead(n)
lower() mode
discard(elem)
utcoffset() Indexes and Slices pow(x,y)
lstrip([chars]) name dst() a=[0,1,2,3,4,5] sqrt(x)
getrandbits(k) pop()
partition(sep) newlines tzname() len(a) 6
randrange([start], stop[, step]) clear()
replace(old, new[, count]) softspace timetuple() Trigonometric Functions
randint(a,b)
rfind(sub[, start[, end]])
a[0] 0
utctimetuple() acos(x)
choice(seq)
rindex(sub[, start[, end]]) Mapping Types toordinal() a[5] 5
shuffle(x[,random]) asin(x)
rjust(width[, fillchar]) len(d) weekday() a[-1] 5 atan(x)
sample(population,k) d[key]
random()
rpartition(sep) isoweekday() a[-2] 4 atan2(y,x)
uniform(a,b)
rsplit([sep[, maxsplit]]) d[key] = value isocalendar() a[1:] [1,2,3,4,5] cos(x)
triangular(low,high,mode)
rstrip([chars])
split([sep[, maxsplit]])
Sys del d[key]
key in d
isoformat()
__str__()
a[:5] [0,1,2,3,4] hypot(x,y)
sin(x)
betavariate(alpha,beta)
splitlines([keepends])
a[:-2] [0,1,2,3]
Sys Variables ctime() tan(x)
expovariate(lambd)
startswith(prefix[, start[, end]]) key not in d a[1:3] [1,2]
strftime()
gammavariate(alpha,beta)
strip([chars]) argv iter(d) a[1:-1] [1,2,3,4]
gauss(mu,sigma) Command line args Angular Conversion
swapcase clear() Time Object b=a[:] Shallow copy of a
lognormvariate(mu,sigma) degrees(x)
title() builtin_module_names copy() replace([hour[, minute[, second
normalvariate(mu,sigma) Linked C modules
radians(x)
translate(table[, deletechars]) fromkeys(seq[, value]) [, microsecond[, tzinfo]]]]])
vonmisesvariate(mu,kappa) byteorder get(key[, default])
upper() isoformat() Hyperbolic Functions
paretovariate(alpha) Native byte order has_key(key)
zfill(width) __str__() acosh(x)
weibullvariate(alpha,beta) check_-interval items()
isnumeric()
isdecimal() Signal check frequency iteritems()
strftime()
utcoffset() OS asinh(x)
atanh(x)
exec_prefix iterkeys() dst()
itervalues() os Variables cosh(x)
Root directory tzname() sinh(x)
executable keys() altsep
pop(key[, default]) tanh(x)
Name of executable Alternative sep
Class exitfunc
popitem()
setdefault(key[, default])
curdir Constants
Exit function name Current dir string
update([other]) math.pi
Special Methods
__new__(cls) String modules
Loaded modules
values
defpath
Default search path
The mathematical constant π =
3.141592..., to available precisi
__lt__(self, other)
__init__(self, args)
Formatting path Date devnull
Path of null device
on.
Search path math.e
__le__(self, other) Formatting Operations platform Formatting extsep
Extension separator
The mathematical constant e =
__del__(self) 'd' Current platform 2.718281..., to available precisi
__gt__(self, other) Signed integer decimal. stdin, stdout, stderr Date Formatting linesep on.
'i' File objects for I/O %a Line separator
__repr__(self) name
Signed integer decimal. version_info Abbreviated weekday (Sun)
__ge__(self, other) Name of OS
'o' Python version info %A
__str__(self) Weekday (Sunday) pardir
Signed octal value. winver
__eq__(self, other) 'u' Version number %b Parent dir string
__cmp__(self, other) Obsolete type – it is identical to Abbreviated month name (Jan) pathsep
__ne__(self, other) 'd'. sys.argv %B Patch separator
__index__(self) 'x' sys.argv[0] foo.py Month name (January) sep
__nonzero__(self) Signed hexadecimal (lowercas %c Path separator
sys.argv[1] bar
__hash__(self) e). Date and time
sys.argv[2] -c
__getattr__(self, name) 'X' sys.argv[3] qux %d
Signed hexadecimal (uppercas Day (leading zeros) (01 to 31)
__getattribute__(self, nam e). sys.argv[4] --h
e) %H
'e' 24 hour (leading zeros) (00 to 2
__setattr__(self, name, attr) Floating point exponential form 3)
__delattr__(self, name) at (lowercase). %I
__call__(self, args, kwargs) 'E' 12 hour (leading zeros) (01 to 1
Floating point exponential form 2)
at (uppercase). %j
'f' Day of year (001 to 366)
Floating point decimal format. %m
'F' Month (01 to 12)
Floating point decimal format. %M
'g' Minute (00 to 59)
Floating point format. Uses low %p
ercase exponential format if exp AM or PM
onent is less than -4 or not less %S
than precision, decimal format o
Second (00 to 61?)
therwise.
%U
'G' Week number1 (00 to 53)
Floating point format. Uses upp
ercase exponential format if exp %w
onent is less than -4 or not less Weekday2 (0 to 6)
than precision, decimal format o %W
therwise. Week number3 (00 to 53)
'c' %x
Single character (accepts integ Date
er or single character string). %X
'r' Time
String (converts any Python obj %y
ect using repr(). Year without century (00 to 99)
's' %Y
String (converts any Python obj Year (2008)
ect using str() %Z
'%' Time zone (GMT)
No argument is converted, resul %%
ts in a '%' character in the resul A literal "%" character (%)
t.
1 de 1 27/02/2020 17:09