首页 > 其他 > 详细

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

时间:2018-09-22 12:09:43      阅读:188      评论:0      收藏:0      [点我收藏+]
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))])

  

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

原文:https://www.cnblogs.com/php-linux/p/9689643.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!