Skip to content

Latest commit

 

History

History
52 lines (30 loc) · 1.17 KB

File metadata and controls

52 lines (30 loc) · 1.17 KB

File Path:

1. Absolute File Path 2. Relative File Path

Absolute File Path:

The root is /.

Absolute file paths always start off relative to the root. It basically just starts from the origin (the root of the computer).

Example:
/work/report.doc

Relative File Path

Relative file path looks in the current folder for the file.

. (single dot): current directory you are in.

.. (double dot): parent directory (the folder right above the current one).

For example:

Absolute file paths: /work/project/main.py

  1. If your current directory is /work/project/, your relative path would be: ./main.py

  2. If your current directory is /work/, your relative path would be: ./project/main.py

Note:
We can write the relative path without ./, like project/main.py


Jumping back to the previous/parent directory :

For each jump you need to use ../

For example if you are in :

  • Windows : F:\python\new-folder
  • Unix/Linux/macOS : /F/python/new-folder (if 'F' were a folder name)

And your text.txt file is in the F directory :
../../test.txt"