案例
(1)过滤掉用户输入中前后多余的空白字符:“ nick2008@gmail.com ”
(2)过滤掉某windows下编辑文本中的 “\r” :“hello world \r\n”
(3)去掉文本中的unicode组合符号(音调):(nǐ)(hǎo)(mā)
核心分析
(1)str.strip(),str.lstrip(),str.rstrip()
(2)切片+拼接
(3)replace或正则的re.sub()
(4)str.trasnslate()
(1)过滤掉用户输入中前后多余的空白字符:“ nick2008@gmail.com ”
(2)过滤掉某windows下编辑文本中的 “\r” :“hello world \r\n”
(3)去掉文本中的unicode组合符号(音调):(nǐ)(hǎo)(mā)
(1)str.strip(),str.lstrip(),str.rstrip()
(2)切片+拼接
(3)replace或正则的re.sub()
(4)str.trasnslate()
本文标题:python(去掉字符串中不需要的字符)
本文链接:https://www.haomeiwen.com/subject/zaakettx.html
网友评论