Home > other >  Help: python can't find the file
Help: python can't find the file

Time:10-17



PYTHON small white for help, why the error can not find a file, my files in the data

CodePudding user response:



To believe that the error message, said there is no this file is,
general reason is not know the path,
You can from two aspects to solve,
1, the code, and have to deal with the files in the same directory, CD to this directory, then the python *. Py code execution,
Or
2, the full path to the directory path with r "c: \... "

If, in accordance with the above way to do it, do you have any questions, please continue to cross-examine,

CodePudding user response:

Using OS. Path. The join () try joining together the file path

CodePudding user response:

Stitching path can use the following code
The import OS
BASE_DIR=OS. The path. The dirname (OS) path) dirname (OS) path) abspath (__file__)))
  • Related