set ipython's default scientific notation threshold

前端 未结 2 1119
眼角桃花
眼角桃花 2021-01-04 11:25

How can I modify the point at which python decides to print in scientific notation?

E.g. I\'d like everything > 1e4 or < 1e-4 to be p

2条回答
  •  借酒劲吻你
    2021-01-04 12:26

    In IPython you can use

    %precision %.4g
    

    this will print floating point values who's absolute value is < 1e-4 or >= 1e4 in scientific notation.

    You can find more information about the %precision command in the IPython API Docs. For string formatting options have a look at the Python Docs

提交回复
热议问题