我正准备从这个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
并调用函数列出带有重音符号的团队不正确。ieSète 现在变成u的\xe8te'
您得到的是unicode字符串的
repr
版本,在列表的各个元素上使用print
,您将得到正确的输出。你知道吗相关问题 更多 >
编程相关推荐