python抽取文件名函数

def extract_file_name(url):
    na1=os.path.split(url)
    na2=os.path.splitext(na1[1])
    return na2

url=r'F:\fdsfd\14-324.txt'
extract_file_name(url)

结果
('14-324', '.txt')

def extract_file_name(url):
    na2=os.path.splitext(url)
    return na2

url=r'F:\fdsfd\14-324.txt'
extract_file_name(url)

('F:\fdsfd\14-324', '.txt')

posted on 2020-12-14 18:17  耀扬  阅读(338)  评论(0编辑  收藏  举报

导航