Python file management [file path]

In python, we often use paths for files. There are usually two types of file paths, namely absolute paths and relative paths.

1. Absolute path:

Generally start from the drive letter, and then search down level by level until you find the required file

Windows绝对路径格式:
C:\Python\python.txt
Linux相对路径格式:
/usr/localinx/confinx.conf

2. Relative path

Sibling relationship: the file we want to use and the python code are in the same folder, just write the file name directly

Upper-level relationship: the file to be used is in the upper-level directory of the python code, and access the upper-level path through .../ (if it is multi-level, use .../.../.../ to access layer by layer)

Subordinate relationship: the files to be used are in the folder at the same level as the python code, accessed through the folder name /

Guess you like

Origin blog.csdn.net/modi88/article/details/130310600