📌  相关文章
📜  如何在python代码示例中将字符串转换为int

📅  最后修改于: 2022-03-11 14:46:35.903000             🧑  作者: Mango

代码示例2
# This kind of conversion of types is known as type casting
# Type of variable can be determined using this function type(variable)
>>> string = '123'
>>> type(string) # Getting type of variable string

>>> integer = int(string) # Converting str to int
>>> type(integer) 

>>> float_number = float(string) # Converting str to float.
>>> type(float_number) 

>>> print(string, integer, float_number)
123 123 123.0