0

I write

print(__file__) 

in JupyterNotebook,and I get enter image description here

I write

print(__file__)

in test.py file ,and run test.py in terminal,and I get the output the file path of the test.py

enter image description here

What is the difference between the execution principle of Jupyter Notebook and python files? Where can I learn about it? How does Python execute?

  • https://docs.python.org/3/reference/import.html#file__ : *"`__file__` is optional. If set, this attribute’s value must be a string. The import system may opt to leave `__file__` unset if it has no semantic meaning (e.g. a module loaded from a database)."* – deceze Oct 31 '21 at 14:39

0 Answers0