How to perform data type conversion in python

silencement
Release: 2019-06-12 14:12:35
Original
3274 people have browsed it

How to perform data type conversion in python

Data type conversion in python is implemented using some functions, such as

Convert x to an integer

int(x [,base ])
Copy after login

Convert x to a long integer

long(x [,base ])
Copy after login

Convert x to a floating point number

float(x )
Copy after login

Create a complex number

complex(real [,imag ])
Copy after login

Convert object x to a string

str(x )
Copy after login

Converts object Tuple

repr(x )
Copy after login

Convert sequence s to a list

eval(str )
Copy after login

Convert an integer to a character

tuple(s )
Copy after login

Convert an integer to a Unicode character

list(s )
Copy after login

Convert a character to its integer value

chr(x )
Copy after login

The above is the detailed content of How to perform data type conversion in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template