小编ali*_*oli的帖子

Python从字符串返回适当的类型

假设需要将字符串转换为适当的类型.例如,如果字符串为:"1.0"则返回1.0 <type 'float'>
"[1.0,2.1,3]"返回[1.0, 2.1, 3] <type 'list'>

这样做有一种聪明的方法吗?

python types

-1
推荐指数
1
解决办法
58
查看次数

标签 统计

python ×1

types ×1