Python的string.whitespace很棒:
>>> string.whitespace '\t\n\x0b\x0c\r '
如何使用字符串而无需手动输入'\ t | \n | ...等正则表达式?
例如,它应该能够变成:"请不要伤害我."
成
"请不要伤害我."
我可能想要保留单个空格,但是我觉得很容易就去string.whitespace [: - 1].
python string whitespace
python ×1
string ×1
whitespace ×1