📜  python代码示例中的类型转换

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

代码示例1
# Converting data type of one variable to diffrent data type is called typecasting
>>> string = '123'
>>> type(string)

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

>>> float_number = float(integer) # Converting int() to float() data type.
>>> type(float_number)

>>> string, integer, float_number
('123', 123, 123.0) # str, int, float