📜  numpy.fromstring()函数– Python

📅  最后修改于: 2022-05-13 01:55:32.318000             🧑  作者: Mango

numpy.fromstring()函数– Python

numpy.fromstring()函数创建一个从字符串中的文本数据初始化的新一维数组。

代码#1:

Python3
# Python program explaining
# numpy.fromstring() function
   
# importing numpy as geek
import numpy as geek
   
gfg = geek.fromstring('1 2 3 4 5', dtype = float, sep = ' ')
   
print(gfg)


Python3
# Python program explaining
# numpy.fromstring() function
   
# importing numpy as geek
import numpy as geek
   
gfg = geek.fromstring('1 2 3 4 5 6', dtype = int, sep = ' ')
   
print(gfg)


输出 :

代码#2:

Python3

# Python program explaining
# numpy.fromstring() function
   
# importing numpy as geek
import numpy as geek
   
gfg = geek.fromstring('1 2 3 4 5 6', dtype = int, sep = ' ')
   
print(gfg)

输出 :