300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > Python Numpy 从文件中读取数据

Python Numpy 从文件中读取数据

时间:2019-04-12 18:16:29

相关推荐

Python Numpy 从文件中读取数据

独角兽企业重金招聘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']]...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。