python numpy np.fromstring()函数(从字符串文本中提取数字,返回一维数组)(爬虫提取数字挺好用的)
生活随笔
收集整理的這篇文章主要介紹了
python numpy np.fromstring()函数(从字符串文本中提取数字,返回一维数组)(爬虫提取数字挺好用的)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
from numpy\core\multiarray.py
def fromstring(string, dtype=None, count=-1, sep=''): # real signature unknown; restored from __doc__"""fromstring(string, dtype=float, count=-1, sep='')A new 1-D array initialized from text data in a string.從字符串中的文本數據初始化的新一維數組。Parameters----------string : strA string containing the data.包含數據的字符串。dtype : data-type, optionalThe data type of the array; default: float. For binary input data,the data must be in exactly this format.數組的數據類型; 默認值:浮動。 對于二進制輸入數據,數據必須完全采用這種格式。 count:int,可選count : int, optionalRead this number of `dtype` elements from the data. If this isnegative (the default), the count will be determined from thelength of the data.從數據中讀取此數量的dtype元素。 如果為負(默認值),則將根據數據長度確定計數。sep : str, optionalThe string separating numbers in the data; extra whitespace betweenelements is also ignored.字符串,分隔數據中的數字; 元素之間的多余空格也將被忽略。.. deprecated:: 1.14If this argument is not provided, `fromstring` falls back on thebehaviour of `frombuffer` after encoding unicode string inputs aseither utf-8 (python 3), or the default encoding (python 2).如果未提供此參數,則在將Unicode字符串輸入編碼為utf-8(python 3)或默認編碼(python 2)后,fromfromstring會退回到frombuffer的行為。Returns-------arr : ndarrayThe constructed array.構造的數組。Raises------ValueErrorIf the string is not the correct size to satisfy the requested`dtype` and `count`.如果字符串的大小不正確,不能滿足要求的`dtype`和`count`。See Also--------frombuffer, fromfile, fromiterExamples-------->>> np.fromstring('1 2', dtype=int, sep=' ')array([1, 2])>>> np.fromstring('1, 2', dtype=int, sep=',')array([1, 2])"""pass示例
總結
以上是生活随笔為你收集整理的python numpy np.fromstring()函数(从字符串文本中提取数字,返回一维数组)(爬虫提取数字挺好用的)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Intel Realsense D435
- 下一篇: websocket python爬虫_p