Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How python Converts String Type to Integer Type
How python Converts String Type to Integer Type
In python, there are two ways to convert a string into an integer: 1, which uses the atoi function in the string library to convert the string into a number; 2. Directly use the built-in function of int to convert the string into numeric type.

(1) Import string?

tt='555 '

ts=string.atoi(tt)

Ts is the number that tt is converted into.

Converted to floating-point number string.atof(tt)

(2) Direct integration

Int(tt) will do.

Recommended course: Python Introduction and Advanced Teaching Video (Geek College)