Answer the question
In order to leave comments, you need to log in
How to change the opening path of a text file when you specify only the name?
When I open a text file for reading or writing, specifying only the file name, vs code opens the file along the path %UserProfile%\"file name"
How to open a file located in the same folder as the code file?
Answer the question
In order to leave comments, you need to log in
I usually use the pathlib library - there is Path ()
Then we do something like:
my_root = Path.cwd() # cwd - current work dir
my_file = Path(“my_file_name.txt”)
my_file_full_path = my_root / myfile
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question