subject = page.select('div.container h1')
subject = [x.text.replace('2015', '')for x in subject]
print subject
[u'\u20132016 Art Courses']# This is the code after.
[u'2015\u20132016 Art Courses']#This is the code before.
subject = [x.text.replace('20132016', '')for x in subject]
当我尝试将.replace改为'20132016'时,它只是打印出来 [u'2015\U2013 2016艺术课程']
有人知道如何摆脱20132016以及
课程。你知道吗
\u2013
是unicode符号en dash
。例如,选中here。你知道吗因此,要摆脱艺术之外的一切,你需要像这样替换它:
字符串中没有“2013”字符。您只有一个字符,unicode 2013,即“–”,一个短划线。你需要替换那个角色。你知道吗
相关问题 更多 >
编程相关推荐