python from pathlib import Path python path = Path('/path/to/file.txt') python for item in path.iterdir(): print(item.name) python from pathlib import Path path = Path('/path/to/file.txt') print('File Name:', path.name) print('File Stem (without extension):', path.stem) print('File Extension:', path.suffix) print('Parent Directory:', path.parent) print('Absolute Path:', path.absolute()) print('Path Exists:', path.exists()) print('Is File:', path.is_file()) print('Is Directory:', path.is_dir()) print('New Path:', new_path) for item in path.parent.iterdir(): print(item.name)


上一篇:
下一篇:
切换中文