如何获取iPython中最后分配的变量的值? [英] How to get the value of the last assigned variable in iPython?

查看:49
本文介绍了如何获取iPython中最后分配的变量的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iPython的新手,但我想知道是否有一种方法可以获取最后分配的变量的值:

I am a total iPython newbie, but I was wondering if there is a way to get the value of the last assigned variable:

In [1]: long_variable_name = 333
In [2]: <some command/shortcut that returns 333>

在R中,我们有 .Last.value :

> long_variable_name = 333
> .Last.value
[1] 333

推荐答案

最后一个返回的对象 _ 有一个快捷方式.

There's a shortcut for the last returned object, _.

In [1]: 1 + 3
Out[1]: 4

In [2]: _
Out[2]: 4

这篇关于如何获取iPython中最后分配的变量的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆