Resources:
1. Basic Python Tutorial
2. http://www.runoob.com/python/python-variable-types.html
3. http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000
Common data type Conversion functions:
function |
Description |
int (x [, Base]) |
Convert x to an integer |
Long (x [, Base]) |
Convert x to a long integer |
Float (x) |
Convert x to a floating-point number |
Complex (real [, Imag]) |
Create a complex number |
STR (x) |
Convert an object x to a string |
REPR (x) |
Convert an object x to an expression string |
eval (str) |
Used to evaluate a valid Python expression in a string and return an object |
Tuple (s) |
Converting a sequence s to a tuple |
List (s) |
Convert the sequence s to a list |
Set (s) |
Convert to mutable Collection |
Dict (d) |
Create a dictionary. D must be a sequence (key,value) tuple. |
Frozenset (s) |
Convert to immutable Collection |
Chr (x) |
Converts an integer to one character |
UNICHR (x) |
Converts an integer to a Unicode character |
Ord (x) |
Converts a character to its integer value |
Hex (x) |
Converts an integer to a hexadecimal string |
Oct (x) |
Converts an integer to an octal string |
Python Basic Learning Notes (ix) Common data type conversion functions