此函数用于通过使用可迭代对象来创建ndarray。它返回一维ndarray对象。
numpy.fromiter(iterable, dtype, count = - 1)
它接受以下参数。
返回使用可迭代对象创建的数组。
import numpy as np list = [0,2,4,6] it = iter(list) x = np.fromiter(it, dtype = float) print(x) print(type(x))
输出:
[0. 2. 4. 6.]
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Spring Cloud 微服务项目实战 -〔姚秋辰(姚半仙)〕