小陆同学

python 中文名:蟒蛇,设计者:Guido van Rossum

导航

python-os模块拆分文件路径和文件名

import os
file_path = "/var/www/project/logs/projectpom.log"
(filepath,tempfilename) = os.path.split(file_path)
(filename,extension) = os.path.splitext(tempfilename)
print("文件路径 ",filepath)
print("文件名(全) ",tempfilename)
print("文件名 ",filename)
print("文件后缀    ",extension)

posted on 2019-12-29 18:06  小陆同学  阅读(5868)  评论(0编辑  收藏  举报