print('__file__:',__file__)
When I do this, the delimiter (/ or \) printed on the console of the development environment is different, but what determines this difference?
__file__:C://...<abbreviated>.../file1.py
__file__: C:\...<Abbreviated >...\file2.py
ffile1 and file2 are in the same folder.
Development Environment
·PC: Windows 10 Pro (20H2 64bit)
·Python 3.9.7
·PyCharm 2021.3 (Community Edition)
Thank you for your cooperation.
Thank you for your comment, quickquip.
file1.py
Now,
if__name__=='__main__':
print_hi('PyCharm')
print('__file__:',__file__)
file2.Func()
It feels like it.
file2.py
In the
def Func():
print('__file__:',__file__)
That's how it goes.So,
file2.py
results from import file2
inside python file1.py
are different from those of file1.py
I think it corresponds to
You can run the environment and files in PyCharm's Run
menu with Debug'file1'
or Debug
to get the results of the questions.
If you run this under Run'file1'
or Run
in PyCharm's Run
menu, both path delimiters will appear under \
.
Even if you run on a single Python interpreter that is not PyCharm, both path delimiters are displayed in half-width で equal to \
.
Even if you operate it in PyCharm's Terminal window, both of them will be \
.
In other words, the file path delimiter that displays different results is considered because it works with PyCharm debugging.
© 2024 OneMinuteCode. All rights reserved.