当我在python中使用csv解析器读取逗号分隔文件或字符串时,所有项目都表示为字符串.见下面的例子.
import csv a = "1,2,3,4,5" r = csv.reader([a]) for row in r: d = row d ['1', '2', '3', '4', '5'] type(d[0]) <type 'str'>
d ['1', '2', '3', '4', '5'] type(d[0]) <type 'str'>
我想确定每个值是否为字符串,浮点数,整数或日期.我怎么能在python中这样做?
python csv types casting
casting ×1
csv ×1
python ×1
types ×1