simplely __ double underscore as a variable name 是什么意思? Just __ not follow another chars

What is the meaning of simply __ double underscore as a variable name? Just __ not follow another chars

当我 运行 ipython 在 Windows 10 上执行 dir 函数时,得到了这个:

Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: dir()
Out[1]:
['In',
 'Out',
 '_',
 '__',
 '___',
 '__builtin__',
 '__builtins__',
 '__doc__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 '_dh',
 '_i',
 '_i1',
 '_ih',
 '_ii',
 '_iii',
 '_oh',
 'exit',
 'get_ipython',
 'quit']

In [2]:

上面有一个___和一个___,这些变量作为内置变量是什么意思?

也没有明白_i_iii的意思,好像这个东西只定义在IPython.

_oh 显示了一个字典,它存储了 ipython.

上的所有输出

_用于:1.解释器,2.名字后,3.名字前 f.e。忽略值:

# Ignore a value 
for _ in range(5) 
    print "Test"

# Ignore a value when unpacking 
a, b, _, _ = my_method(var1)

根据IPython docs_* 值缓存最近输出的值:

The following variables always exist:

  • _ (a single underscore): stores previous output, like Python’s default interpreter.
  • __ (two underscores): next previous.
  • ___ (three underscores): next-next previous.

相反,_i* 变量 store recent inputs:

_i, _ii, _iii: store previous, next previous and next-next previous inputs.