【发布时间】:2015-06-10 03:02:29
【问题描述】:
从标题中我知道你可能认为这是重复的,但事实并非如此。
for id,row in enumerate(rows):
columns = row.findall("td")
teamName = columns[0].find("a").text, # Lag
playedGames = columns[1].text, # S
wins = columns[2].text,
draw = columns[3].text,
lost = columns[4].text,
dif = columns[6].text, # GM-IM
points = columns[7].text, # P - last column
dict[divisionName].update({id :{"teamName":teamName, "playedGames":playedGames, "wins":wins, "draw":draw, "lost":lost, "dif":dif, "points":points }})
这就是我的 Python 代码的样子。大部分代码已被删除,但基本上我是从网站中提取一些信息。我将信息保存为字典。当我打印字典时,每个值都有一个括号 ["blbal"],这会导致我的 Iphone 应用程序出现问题。我知道我可以将变量转换为字符串,但我想知道是否有办法将信息直接作为字符串获取。
【问题讨论】:
标签: python python-2.7 xpath lxml