本文簡要介紹 python 語言中 scipy.io.readsav
的用法。
用法:
scipy.io.readsav(file_name, idict=None, python_dict=False, uncompressed_file_name=None, verbose=False)#
讀取 IDL .sav 文件。
- file_name: str
IDL 保存文件的名稱。
- idict: 字典,可選
插入 .sav 文件變量的字典。
- python_dict: 布爾型,可選
默認情況下,返回的對象不是 Python 字典,而是一個不區分大小寫的字典,具有對變量的項、屬性和調用訪問權限。要獲取標準 Python 字典,請將此選項設置為 True。
- uncompressed_file_name: str,可選
此選項僅對使用 /compress 選項寫入的 .sav 文件有效。如果指定了文件名,則壓縮的 .sav 文件將解壓縮到該文件中。否則,readsav 將使用
tempfile
模塊自動確定臨時文件名,並在成功讀入臨時文件後將其刪除。- verbose: 布爾型,可選
是否打印有關保存文件的信息,包括讀取的記錄和可用變量。
- idl_dict: AttrDict 或字典
如果 python_dict 設置為 False(默認),則此函數返回一個不區分大小寫的字典,其中包含對變量的項、屬性和調用訪問權限。如果 python_dict 設置為 True,則此函數返回一個 Python 字典,其中所有變量名都為小寫。如果指定了 idict,則將變量寫入指定的字典,並返回更新的字典。
參數 ::
返回 ::
例子:
>>> from os.path import dirname, join as pjoin >>> import scipy.io as sio >>> from scipy.io import readsav
從測試/數據目錄中獲取示例 .sav 文件的文件名。
>>> data_dir = pjoin(dirname(sio.__file__), 'tests', 'data') >>> sav_fname = pjoin(data_dir, 'array_float32_1d.sav')
加載 .sav 文件內容。
>>> sav_data = readsav(sav_fname)
獲取 .sav 文件內容的 key 。
>>> print(sav_data.keys()) dict_keys(['array1d'])
使用 key 訪問內容。
>>> print(sav_data['array1d']) [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
相關用法
- Python SciPy io.whosmat用法及代碼示例
- Python SciPy io.savemat用法及代碼示例
- Python SciPy io.loadmat用法及代碼示例
- Python SciPy io.mminfo用法及代碼示例
- Python SciPy io.netcdf_file用法及代碼示例
- Python SciPy io.mmread用法及代碼示例
- Python SciPy io.hb_read用法及代碼示例
- Python SciPy io.FortranFile用法及代碼示例
- Python SciPy io.mmwrite用法及代碼示例
- Python SciPy io.hb_write用法及代碼示例
- Python SciPy interpolate.make_interp_spline用法及代碼示例
- Python SciPy interpolate.krogh_interpolate用法及代碼示例
- Python SciPy interpolative.reconstruct_matrix_from_id用法及代碼示例
- Python SciPy interpolate.InterpolatedUnivariateSpline用法及代碼示例
- Python SciPy interpolate.BSpline用法及代碼示例
- Python SciPy integrate.quad_vec用法及代碼示例
- Python SciPy interpolative.reconstruct_interp_matrix用法及代碼示例
- Python SciPy interpolate.LSQSphereBivariateSpline用法及代碼示例
- Python SciPy interpolate.griddata用法及代碼示例
- Python SciPy integrate.cumulative_trapezoid用法及代碼示例
- Python SciPy interpolate.splder用法及代碼示例
- Python SciPy interpolate.LinearNDInterpolator用法及代碼示例
- Python SciPy interpolate.PPoly用法及代碼示例
- Python SciPy interpolate.NdBSpline用法及代碼示例
- Python SciPy interpolate.pade用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.io.readsav。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。