与联通打交道

2024-09-30 20:37:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我为runescape wiki开发了mwhair。不过,每当我遇到unicode问题时,我总是会遇到这样的问题,比如说一个页面:

This is a page, that has words
To go here to there follow these directions:
Backwards « Forwards
That is all

如果只是做mwhair.edit('Page above'),我会得到一个unicode错误。你知道吗

我尝试通过以下方式解决此问题:

text = mwhair.edit('Page above').encode('ascii','xmlcharrefreplace')
mwhair.save('Page above',text=text)

这似乎是一个解决方案,因为不会出现错误,但它会更改页面的某些内容,例如将行更改为:

Backwards « Forwards

这不会影响任何链接、图片或实际页面输出,但会使bot看起来好像有错误。有什么我搞砸了还是不知道?(我使用的是Python2.7.3)


Tags: textis错误wikipageunicode页面this