Python tools used for file name devision

时间:2023-03-08 17:24:44
Python tools used for file name devision

今天因为工作的缘故,需要用Python写一个能够完全分解文件名的小程序。

import os 

#path = os.path.abspath('.')
def split_fully(name):
parent_name,appendix = os.path.splitext(name)
if appendix == '':
return (parent_name,)
else:
return split_fully(parent_name) + (appendix, ) name = 'E-GEOD-66998.processed.1.zip'
result = split_fully(name)
print(result)

结果:  

Python tools used for file name devision