我为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)
在line 230上,您有:
text
在那一点上是Unicode,所以您可能希望在那一点上对它进行编码。我想MediaWiki需要UTF-8:
相关问题 更多 >
编程相关推荐