Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert string into int in python
How to convert string into int in python
Initializing the int class with a numeric string can convert an integer string (str) into an integer (int):

In [ 1]: int(' 1234 ')?

Out[ 1]: 1234

On the contrary, by initializing the str class with integers, you can convert integers (int) into corresponding strings (str):

In [2]: str( 1234)?

Out[2]: ' 1234 '

If the string is a floating-point number, you can initialize the float class with the string and convert the floating-point number string (str) into a floating-point number (float):

In [3]: float(' 12.34 ')?

Out[3]: 12.34

Extended data:

Python (British pronunciation:/? Dad? θ? N/ American pronunciation:/? Dad? θɑ? N/), an object-oriented explanatory computer programming language, was invented by Dutch Guido van Rossum in 1989 and first published in 199 1.

Python is pure free software. The source code and interpreter CPython follow GPL(GNU? General public license). Python syntax is concise, and one of its characteristics is to force the use of spaces as statement indents.

Python has a rich and powerful library. Often dubbed glue language, it can easily connect various modules made by other languages (especially C/C++). A common application situation is to use Python to quickly generate the prototype of the program (sometimes even the final interface of the program), and then rewrite the parts with special requirements in a more suitable language, such as the graphics rendering module in 3D games, which has particularly high performance requirements and can be rewritten in C/C++, and then encapsulated into an extended class library that Python can call. It should be noted that when using extended class libraries, platform issues may need to be considered, and some may not provide cross-platform implementation.

On July 20th, IEEE released the list of 20 17 programming languages: Python ranked first.

On March 20 18, the author of the language announced on the mailing list that Python 2.7 would end its support in June 2020+10. If users want to continue to get Python 2.7 related support after this date, they need to pay the commercial provider.

References:

CSDN