python创建文件时去掉非法字符

windows系统中文件名不能包含 \ / : * ? " < > |想要创建必须过滤掉这些字符

import re
 
def filename_filter(filename):   
    filename = re.sub('[\/:*?"<>|]','',filename)
    return filename

猜你喜欢

转载自www.cnblogs.com/lvchengda/p/12614214.html