1

I tried to use "_" in python command line and it's working as well.

In [1]: 1234
Out[1]: 1234

In [2]: _
Out[2]: 1234

In [3]: print _
1234

In [4]: 'aaaaa'
Out[4]: 'aaaaa'

In [5]: print _
aaaaa

In [6]:

but there is a problem when i using this in a python file. content of file:

'aaaa'
print _

returned error:

Traceback (most recent call last):
  File "C:\somefolder\f.py", line 2, in <module>
    print _
NameError: name '_' is not defined

what's the problem ? how I can fix it ? is there anything to replace with "_" and do the same work ?

user3671325
  • 306
  • 2
  • 6
  • 14

0 Answers0