正则表达式

正则表达式学习链接

http://deerchao.net/tutorials/regex/regex.htm#greedyandlazy

 

1、删除任意空白字符(换行符,空字符等)

>>> a="\t\t\n 123"
>>> a
'\t\t\n 123'
>>> b = re.sub(r'\s+','', a) #\s   匹配任意的空白符
>>> b
'123'

  

 

posted @ 2017-04-13 15:47  kingrain  阅读(123)  评论(0编辑  收藏  举报