VOOZH about

URL: https://www.geeksforgeeks.org/python/numpy-fromstring-function-python/

⇱ numpy.fromstring() function – Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

numpy.fromstring() function – Python

Last Updated : 18 Aug, 2020

numpy.fromstring() function create a new one-dimensional array initialized from text data in a string.

Syntax : numpy.fromstring(string, dtype = float, count = -1, sep = ' ')

Parameters :

string : [str] A string that contained the data.

dtype : [data-type, optional] Data-type of the array. Default data type is float.

count : [int, optional] Number of items to read. If this is negative (the default), the count will be determined from the length of the data.

sep : [str, optional] The string separating numbers in the data.

Return : [ndarray] Return the constructed array.

Code #1 :

Output :

[1. 2. 3. 4. 5.]

Code #2 :

Output :

[1 2 3 4 5 6]

Comment
Article Tags:
Article Tags: