我用Python编写一个爬虫程序,当我抓取德语页面并将其写入txt文件时,它不会写“Ö”、“Ä”或“Ü”,而是\xD6、\xF6、。。。取而代之的是
有什么办法解决吗?在
ortschaften = list()
text_file = open("Output_Brandenburg.txt", "w")
for x in xrange(1,99):
ortschaft = str(response.xpath('//*[@id="orte"]/div[1]/ul/li[' + str(x) + ']/a/text()').extract())
ortschaft.replace("\xD6", "Oe")
ortschaft.replace("\xF6", "oe")
ortschaft.replace("\xAE", "Ae")
ortschaft.replace("\xE4", "ae")
ortschaft.replace("\xDC", "Ue")
ortschaft.replace("\xFC", "ue")
print ortschaft
text_file.write(ortschaft + "\n")
if ortschaft is not None:
ortschaften.append(ortschaft)
pass
我的输出例如:
^{pr2}$
目前没有回答
相关问题 更多 >
编程相关推荐