What is the difference between "./file_name", "../file_name" and "file_name"when used as the file path in Python?
For example, if you want to save in the file_path, is it correct that "../file_name" will save file_name inside the current directory? And "./file_name" will save it to the desktop? It's really confusing.
./file_name and file_name mean the same thing - a file called file_name in the current working directory.
../file_name means a file called file_name in the in the parent directory of the current working directory.
Summary
. represents current directory whereas .. represents parent directory.
Explanation by example
if the current working directory is this/that/folder then:
. results in this/that/folder.. results in this/that../.. results in this.././../other results in this/otherIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With