本文簡要介紹 python 語言中 numpy.DataSource
的用法。
用法:
class numpy.DataSource(destpath='.')
通用數據源文件(文件、http、ftp、...)。
DataSources可以是本地文件或遠程文件/URL。文件也可以是壓縮的或未壓縮的。 DataSource隱藏了下載文件的一些低級細節,允許您簡單地傳入有效的文件路徑(或URL)並獲取文件對象。
- destpath: str 或無,可選
源文件下載到以供使用的目錄的路徑。如果 destpath 為 None,將創建一個臨時目錄。默認路徑是當前目錄。
參數:
注意:
URL 需要使用方案字符串(
http://
),沒有它它們將失敗:>>> repos = np.DataSource() >>> repos.exists('www.google.com/index.html') False >>> repos.exists('http://www.google.com/index.html') True
刪除 DataSource 時,臨時目錄也會被刪除。
例子:
>>> ds = np.DataSource('/home/guido') >>> urlname = 'http://www.google.com/' >>> gfile = ds.open('http://www.google.com/') >>> ds.abspath(urlname) '/home/guido/www.google.com/index.html' >>> ds = np.DataSource(None) # use with temporary file >>> ds.open('/home/guido/foobar.txt') <open file '/home/guido.foobar.txt', mode 'r' at 0x91d4430> >>> ds.abspath('/home/guido/foobar.txt') '/tmp/.../home/guido/foobar.txt'
相關用法
- Python numpy RandomState.standard_exponential用法及代碼示例
- Python numpy hamming用法及代碼示例
- Python numpy legendre.legint用法及代碼示例
- Python numpy chararray.ndim用法及代碼示例
- Python numpy chebyshev.chebsub用法及代碼示例
- Python numpy chararray.nbytes用法及代碼示例
- Python numpy ma.indices用法及代碼示例
- Python numpy matrix.A1用法及代碼示例
- Python numpy MaskedArray.var用法及代碼示例
- Python numpy ma.zeros用法及代碼示例
- Python numpy broadcast用法及代碼示例
- Python numpy matrix.T用法及代碼示例
- Python numpy matrix.I用法及代碼示例
- Python numpy MaskedArray.T用法及代碼示例
- Python numpy hermite.hermfromroots用法及代碼示例
- Python numpy hermite_e.hermediv用法及代碼示例
- Python numpy recarray.dot用法及代碼示例
- Python numpy random.mtrand.RandomState.wald用法及代碼示例
- Python numpy trim_zeros用法及代碼示例
- Python numpy chebyshev.chebdiv用法及代碼示例
- Python numpy linalg.svd用法及代碼示例
- Python numpy copy用法及代碼示例
- Python numpy negative用法及代碼示例
- Python numpy ndarray.astype用法及代碼示例
- Python numpy ma.diff用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.DataSource。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。