1
for i in names:
dict[i] = {'firstname': name[i]['firstname'],
'lastname': name[i]['lastname']}
print dict[0]['firstname'] # John
print dict[0]['lastname'] # Doe
# group similar lastnames, along with their firstnames
# ...
return render_to_response('index.html', dict)
我想要以相似的姓氏结尾的姓名组合。 例如,输出应该是:Python字典问题。如何分组类似的字符串?
<html>
<body>
<h1> Doe </h1>
<p> John, Jason, Peter </p>
<h1> Avery </h1>
<p> Kelly, Brittany </p>
</body>
</html>
的“H1”的标签都应该包含最后名称和“P”标签第一名称。
我该怎么做?
通过“similar”你实际上是指“相等”? – 2011-01-18 21:52:43
糟糕。是的,这就是我的意思。 – user216171 2011-01-18 23:29:29