num1 = 1
str1 = ‘10’
print(type(float(num1)))
print(num1)
print((float(num1)))
output:
<class ‘float’>
1
1.0
整型num1用type转换成浮点型后,直接输出还是整型,还要用float。
若用eval(str)转换后,输出不需用加数据类型
str2 = ‘1’
str3 = ‘(1000,2000,400)’
print(type(eval(str2)))
print(type(eval(str3)))
print(str2)
print(str3)
output:
<class ‘int’>
<class ‘tuple’>
1
(1000,2000,400)