Show Menu
Cheatography

Python 2.7 Modules Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

os

Pipe Open
popen( cmd[, mode[, bufsize]] )
In Memory Temp File
tmpfile()
List Directory Entries
listdir( path )
Rename File
rename( src, dst )
File Stats
stat( path )

Access Modes

r
Read
rb
Read
Binary
r+
Read/ Write
rb+
Read/ Write
Binary
w
Write
Create­/Ov­erwrite
wb
Write
Create­/Ov­erwrite
w+
Read/ Write
Create­/Ov­erwrite
wb+
Read/ Write
Binary, Create­/Ov­erwrite
a
Append
ab
Append
Binary
a+
Read/ Append
ab+
Read/ Append
Binary

File I/O

Open
f = open( name [, access­_mo­de][, buffering] )
Close
f.close()
Write
f.write( string )
Read
f.read( [bytes] )
Location
f.tell()
Position
f.seek( off[, from ] )
from == 0: From Beginning
   
from == 1: From Current Pos
   
from == 2: From End
 

re

Search
`kk