The concept of a path file
The document is good to understand, for example the a.txt under D disk is a file.
The path refers to the location of the file on the operating system, such as the D disk, which indicates a location, that is, the path. two, Windows and Linux for different processing of the path
Like two programmers, the habit of writing the program is different, two operating systems on the path of the rules are not the same.
Windows is using \, and Linux is using the/,windows root directory is the disk character C:\, and the Linux root directory is/
For example
C:\a.txt
/mnt/a.txt
Third, string expression of file path
Linux is very well understood, just add single or double quotes
"/mnt/a.txt"
'/mnt/a.txt '
Because the \ is an escape character used in Windows, you can use \ to express a \ 's true meaning in a string.
"C:\\a.txt" "
C:\a.txt"
Four, absolute path and relative path
The so-called absolute path, refers to the path from the root directory.
The so-called relative path, refers to the current working directory, the current working directory refers to the program locked in the directory.
For the current directory. Represents the parent directory.
Like what:
program file: C:\temp\a.py
a.txt indicates that C:\temp\a.txt
. \a.txt represents C:\temp\a.txt
. \a.txt says C:\a.txt
. \tt\a.txt says C:\\tt\a.txt