NumPy Input and Output: printoptions() function

numpy.printoptions() function

The printoption() function is a context manager for setting print options.

Set print options for the scope of the with block, and restore the old options at the end.


numpy.printoptions(*args, **kwargs)

Version: 1.15.0

NumPy.printoptions() method Example:

>>> import numpy as np
>>> with np.printoptions(precision=3):
...     print(np.array([3.0/4]))



The as-clause of the with-statement gives the current print options:

>>> with np.printoptions(precision=2) as opts:
...      assert_equal(opts, np.get_printoptions())

Python - NumPy Code Editor:

Previous: set_string_function()
Next: binary_repr() function

Follow us on Facebook and Twitter for latest update.