The difference between the current folder path of Pycharm and VScode
Usually, VScode and Pycharm are used alternately. One is lightweight and the other is more convenient for debugging. But today I suddenly found that the file that can be run in vscode reported an error in pycharm. After debugging for a long time, pay attention to avoid pits.
In the above file structure [KKKK]–>[111]–>[xxx.py], run the os.getcwd() command in VScode and Pycharm respectively, and get the following results: Vscode: shows the
main
directory of the opened folder
Pycharm
shows the folder directory where the current file is located
Reason : vscode defaults to the root path of the project as the current path
Solution : After trying, the methods given on the Internet such as adding [${fileDirname}] and ticking the box in the figure below cannot solve this problem.