This is a draft cheat sheet. It is a work in progress and is not finished yet.
Max value
In Python, value of an integer is not restricted by the number of bits and can expand to the limit of the available memory |
Transpose
matrix |
[[m[j][i] for j in range(len(m))] for i in range(len(m[0]))] |
array |
zip(*matrix) |
array |
numpy.transpose(matrix)) |
Type Conversion
int(a,base) |
int |
float() |
float point |
ord() |
char to int |
hex() |
integer to hexadecimal string |
oct() |
integer to octal string |
tuple() |
convert to a tuple |
set() |
type after converting to set |
list() |
any data type to a list type |
dict() |
a tuple of order (key,value)to dict |
str() |
int to str |
complex(real,imag) |
real numbers to complex(real,imag) number |
|
|
Byte Obj vs String
a.encode('ASCII'),b.decode('ASCII')
|
|
|
|
|