new_name = '' biaoji = False for itype in type: if fnmatch.fnmatch(filename,'*'+itype): new_name = filename[:-len(itype)] + '.txt' biaoji = True break if biaoji==False: print('格式不正确') exit(0)
这样显得代码很烂,有没有简洁好看的方法
pardon110
相关分类