http://www.tutorialspoint.com/python/python_variable_types.htm
Data Type Conversion
Sometimes, you may need to perform conversions between the built-in types. To convert between types, you simply use the type name as a function.
There are several built-in functions to perform conversion from one data type to another. These functions return a new object representing the converted value.
Function | Description |
---|---|
int(x [,base]) | Converts x to an integer. base specifies the base if x is a string. |
long(x [,base] ) | Converts x to a long integer. base specifies the base if x is a string. |
float(x) | Converts x to a floating-point number. |
complex(real [,imag]) | Creates a complex number. |
str(x) | Converts object x to a string representation. |
repr(x) | Converts object x to an expression string. |
eval(str) | Evaluates a string and returns an object. |
tuple(s) | Converts s to a tuple. |
list(s) | Converts s to a list. |
set(s) | Converts s to a set. |
dict(d) | Creates a dictionary. d must be a sequence of (key,value) tuples. |
frozenset(s) | Converts s to a frozen set. |
chr(x) | Converts an integer to a character. |
unichr(x) | Converts an integer to a Unicode character. |
ord(x) | Converts a single character to its integer value. |
hex(x) | Converts an integer to a hexadecimal string. |
oct(x) | Converts an integer to an octal string. |
'Python > Study' 카테고리의 다른 글
Python | Study | ipaddress 설치 (0) | 2016.01.22 |
---|---|
Python | Study | pytest 설치 및 사용법 (0) | 2016.01.22 |
Python | Study | lambda function Basic (0) | 2016.01.14 |
Python | Examples | OpenPyXL 사용하기 | python - excel 파일 다루기 (0) | 2016.01.13 |
JSON 초간단 사용법 (0) | 2015.12.15 |