美文网首页
python学习笔记

python学习笔记

作者: V_嘉 | 来源:发表于2018-03-18 14:24 被阅读0次

python的替换函数:

出现的使用场景之一:新建文件夹时过滤掉非法字符

    .replace(rgExp, replaceText, max)

    re.sub(pattern, repl, string, count, flags)

    .strip(stripString)


.replace():

.replace()

re.sub():

re.sub()

.strip():

当参数为空时默认只删除头尾的空白符,不能删除中间的 lstrip删除左边开头的字符,rstrip删除右边尾端的字符

相关文章

网友评论

      本文标题:python学习笔记

      本文链接:https://www.haomeiwen.com/subject/iypeqftx.html