Here is the structure of the folder:
- python
- python study
- study.py
- a.txt
The code in study.py is:
import os
if(os.path.exists("a.txt")):
print("YES") # my real code is not this
else:
print("NO")
Usually I open thepython study
folder as pycharm project,like this:
And the result is YES
.
But today I carelessly open the python
folder(not python study
) as pycharm project and run the code.
The result is NO
. Finally,I find it refer to the python
(project path) instead of the folder of the .py file.What's the purpose of this?
After this, I run this code in cmd,and the result is YES
.
I think it some time will bring some problems while develop project with other people.(If someone use notepad instead of pycharm to edit code and run code in cmd).