Python Cheetsheet
Python Cheetsheet
argv builtin_module_names byteorder check_interval exec_prefix executable exitfunc modules path platform stdin,stdout,stderr version_info winver Command line args Linked C modules Native byte order Signal check frequency Root directory Name of executable Exit function name Loaded modules Search path Current platform File objects for I/O Python version info Version number capitalize() * center(width) count(sub,start,end) decode() encode() endswith(sub) expandtabs() find(sub,start,end) index(sub,start,end) isalnum() * isalpha() * isdigit() * islower() * isspace() * istitle() * isupper() * join() ljust(width) lower() *
NOTE
String Methods
lstrip() partition(sep) replace(old,new) rfind(sub,start,end) rindex(sub,start,end) rjust(width) rpartition(sep) rsplit(sep) rstrip() split(sep) splitlines() startswith(sub) strip() swapcase() * title() * translate(table) upper() * zfill(width) %a %A %b %B %c %d %H %I %j %m %M %p %S %U %w %W %x %X %y %Y %Z %% replace() isoformat() __str__() strftime(formato)
Time Methods
utcoffset() dst() tzname()
os Variables
altsep curdir defpath devnull extsep linesep name pardir pathsep sep
NOTE
Alternative separator Current dir string Default search path Path of null device Extension separator Line separator Name of OS Parent dir string Path separator Path separator OS name can be posix, nt, mac, os2, ce, java or riscos len(a) a[0] a[5] a[-1] a[-2] a[1:] a[:5] a[:-2] a[1:3] a[1:-1] append(item) count(item) extend(list) index(item) insert(position,item)
List Methods
pop(position) remove(item) reverse() sort()
1 -- Not a mistake. Range takes account of leap seconds 2 -- Sunday as start of week. 3 -- 0 is Sunday, 6 is Saturday. 4 -- Monday as start of week.
File Methods
close() flush() fileno() isatty() next() read(size) readline(size) Created with rst2pdf: Droid Typeface: Homepage: http://rst2pdf.googlecode.com http://www.droidfonts.com http://netmanagers.com.ar/machete readlines(size) seek(offset) tell() truncate(size) write(string) writelines(list)
Datetime Methods
today() now(timezoneinfo) utcnow() fromtimestamp(timestamp) fromordinal(ordinal) combine(date,time) strptime(date, format) utcfromtimestamp(timestamp)
Non-Commercial
Share Alike