numpy.printoptions#
- numpy.printoptions(*args, **kwargs)[原始碼]#
用於設定列印選項的上下文管理器。
在 with 區塊的範圍內設定列印選項,並在結束時還原舊選項。請參閱
set_printoptions
以取得可用選項的完整說明。範例
>>> import numpy as np
>>> from numpy.testing import assert_equal >>> with np.printoptions(precision=2): ... np.array([2.0]) / 3 array([0.67])
with 語句的 as 子句提供目前的列印選項
>>> with np.printoptions(precision=2) as opts: ... assert_equal(opts, np.get_printoptions())