测试文件内容(test1.txt)
代码语言:javascript复制hello,123,nihao
8,9,10
io,he,no
测试代码
代码语言:javascript复制import numpy
# dtype:默认读取数据类型,delimiter:分隔符
world_alcohol = numpy.genfromtxt("test1.txt", dtype=str, delimiter=",")
# 数据结构
print(type(world_alcohol))
# 数据内容
print(world_alcohol)
# 帮助文档
print(help(numpy.genfromtxt))
结果
代码语言:javascript复制<class 'numpy.ndarray'>
[['hello' '123' 'nihao']
['8' '9' '10']
['io' 'he' 'no']]
...