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')