独角兽企业重金招聘Python工程师标准>>>
测试文件内容(test1.txt)
hello,123,nihao8,9,10io,he,no
测试代码
import numpy# dtype:默认读取数据类型,delimiter:分隔符world_alcohol = numpy.genfromtxt("test1.txt", dtype=str, delimiter=",")# 数据结构print(type(world_alcohol))# 数据内容print(world_alcohol)# 帮助文档print(help(numpy.genfromtxt))
结果
<class 'numpy.ndarray'>[['hello' '123' 'nihao']['8' '9' '10']['io' 'he' 'no']]...