031 解析工作簿的路径信息
from pathlib import Path file_path = Path(r'D:python_filereceiving.xlsx') path = file_path.parent # 提取工作簿所在文件夹的路径 file_name = file_path.name # 提取工作簿的文件名 stem_name = file_path.stem # 提取工作簿的文件主名 suf_name = file_path.suffix # 提取工作簿的扩展名 print(path) print(file_name) print(stem_name) print(suf_name)
C:Usersjjsheanaconda3python.exe “D:/Python/150例/031 解析工作簿的路径信息.py”
D:python_file
receiving.xlsx
receiving
.xlsx
Process finished with exit code 0
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)