淘先锋技术网

首页 1 2 3 4 5 6 7

I have a python specific question. What does a single underscore _ as a parameter means?

I have a function calling hexdump(_). The _ was never defined, so I guess it has some special value, I could not find a reference telling me what it means on the net. I would be happy if you could tell me.

解决方案

In Python shells, the underscore (_) means the result of the last evaluated expression in the shell:

>>> 2+3

5

>>> _

5

There's also _2, _3 and so on in IPython but not in the original Python interpreter. It has no special meaning in Python source code as far as I know, so I guess it is defined somewhere in your code if it runs without errors.