在交互式 Python shell 中获取最后结果 [英] Get last result in interactive Python shell
本文介绍了在交互式 Python shell 中获取最后结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在许多符号数学系统中,例如 Matlab 或 Mathematica,您可以使用诸如 Ans
或 %
之类的变量来检索最后计算出的值.Python shell 中是否有类似的功能?
解决方案
下划线.
<预><代码>>>>5+510>>>_10>>>_ + 515>>>_15In many symbolic math systems, such as Matlab or Mathematica, you can use a variable like Ans
or %
to retrieve the last computed value. Is there a similar facility in the Python shell?
解决方案
Underscore.
>>> 5+5
10
>>> _
10
>>> _ + 5
15
>>> _
15
这篇关于在交互式 Python shell 中获取最后结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文