【发布时间】:2014-01-25 19:40:10
【问题描述】:
我很想从这个 xml 提要导入 http://www.lnv.fr/xml/ajaccio/calendrier.xml 我遇到了一些麻烦,因为我要提取的一些数据有法语重音符号。
url = 'http://www.lnv.fr/xml/ajaccio/calendrier.xml'
r = requests.get(url)
soup = BeautifulSoup(r.content)
matches = soup.findAll('match')
当我这样做时
for match in matches:
print match.equipedomicile.string
它将它们打印出来,因为对于带有重音符号(例如 Sète)的团队来说没有问题。
但是当我这样做时
def GetGames():
homeTeamList = []
for match in matches:
homeTeam = unicode(match.equipedomicile.text)
homeTeamList.append(homeTeam)
return homeTeamList
并调用带有重音符号的列表团队的功能不正确。即赛特 现在变成 u'S\xe8te'
【问题讨论】:
标签: python xml python-2.7 unicode python-2.x