如果想单独提取文件的后缀,可查看Path对象的suffix属性。
>>> file_path = Path('closures.py')... print("文件后缀:", file_path.suffix)...File Extension: .py