爬虫学习之-返回合法文件名

def validateTitle(title):
    rstr = r"[\/\\\:\*\?\"\<\>\|]"  # '/ \ : * ? " < > |'
    new_title = re.sub(rstr, "_", title)  # 替换为下划线
    return new_title

获取文件的总数

def get_total_files(mkpath):
    return sum([len(x) for _, _, x in os.walk(os.path.dirname(mkpath))])

  

猜你喜欢

转载自www.cnblogs.com/php-linux/p/9689643.html