我正在寻找类似TRIM()python 的东西,但.strip()没有做到这一点。下面是一个例子:
>>> s.strip()
'Elvis Presley made his film debut in this tale of three brothers who,
while serving in the Confederate Army, steal a Union Army payroll. \xc2\xa0'
>>> s2.strip()
'Elvis Presley made his film debut in this tale of three brothers who,
while serving in the Confederate Army, steal a Union Army payroll.'
>>> s.strip()==s2.strip()
False
我将如何完成上述任务——修剪文本边缘的所有空白字符——我可以在哪里得到s.trim() == s2.trim()(除了做一个 hackish s.strip('\xc2\xa0').strip()?
桃花长相依
暮色呼如
相关分类