numpy.
printoptions
(* args,** kwargs )[源代码] ¶上下文管理器,用于设置打印选项。
为with块的范围设置打印选项,最后恢复旧选项。请参阅set_printoptions
以获取可用选项的完整说明。
也可以看看
例子
>>> from numpy.testing import assert_equal
>>> with np.printoptions(precision=2):
... np.array([2.0]) / 3
array([0.67])
该作为的-clause 与语句来给出当前打印选项:
>>> with np.printoptions(precision=2) as opts:
... assert_equal(opts, np.get_printoptions())