#是否存在该路径
os.path.exists(path: StrOrBytesPath) -> bool
#创建文件夹
os.mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ...) -> None
#返回该文件夹下子文件夹的路径和文件名称列表
os.listdir(path: PathLike[str]) -> list[str]
#该路径是不是文件夹
os.path.isdir(s: StrOrBytesPath) -> bool
#该路径是不是文件
os.path.isfile(path: StrOrBytesPath) -> bool
'''
os.walk()使用方法
r:表示根目录
dir:是该根目录下的文件夹
files:是该根目录下除文件夹下外的所有文件
for r, dirs,files in os.walk(data_path):
'''
os.walk(top: AnyStr | PathLike[AnyStr], topdown: bool = ..., onerror: _onError | None = ..., followlinks: bool = ...
)
'''
os.path.join使用方法
import os
Path1 = 'home'
Path2 = 'develop'
Path3 = 'code'
Path20 = os.path.join(Path1,Path2,Path3)
print ('Path20 = ',Path20)
Path20 = homedevelopcode
'''
os.path.join(a: BytesPath, *paths: BytesPath)
#获取绝对路径
os.path.dirname(os.path.realpath(__file__))
#获取父文件夹名称
os.path.dirname(pwd)