假设需要将字符串转换为适当的类型.例如,如果字符串为:"1.0"则返回1.0 <type 'float'> "[1.0,2.1,3]"返回[1.0, 2.1, 3] <type 'list'>
1.0 <type 'float'>
[1.0, 2.1, 3] <type 'list'>
这样做有一种聪明的方法吗?
python types
python ×1
types ×1