📜  python remove - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:10.976000             🧑  作者: Mango

代码示例3
>>> s="abc \n \t \t\t \t \nefg"
>>> ''.join(s.split())
'abcefg'
>>> ''.join(c for c in s if not c.isspace())
'abcefg'

import re

s = 'abc \n \t \t\t \t \nefg'
re.sub(r'\s', '', s)
=> 'abcefg'