[英]Concatenation in Python, concatenating lists and strings
我不確定這是否是正確的語法,但是我想打印出列表中的特定元素。
user,activity,data=readfile('data.txt')
kclust,clusters=kcluster(data,k=3)
for i in range(len(kclust)):
print "Cluster %d: ??" % (i+1,clusters[i])
print [[userobjectIds[r] for r in kclust[i]][:3]]
print
'??' 是我嘗試%d和%o的地方,但得到:“ TypeError:%o format:數字是必需的,而不是列表”
我不知道kcluster函數,但似乎它返回一個列表,而不是一個數字。 或者,您可以嘗試:
print "Cluster %d:"%(i+1), clusters[i]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.