今天因为工作的缘故,需要用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)
时间: 2024-10-11 05:28:39