0
for k, v in sorted(total_prob.items(), key = lambda x: x[1], reverse=True):
MLE_Prob, Bi_Prob = v
# here, k = tuple type of bigrams. v = tuple type of (mle prob, bi prob)
print tabulate([k,v[0], v[1]], headers = ["Bigram", "MLE_Prob", "Bi_Prob"], tablefmt="grid")
我的數據包括像{(a,b):(c,d)}。我想打印的結果是如何以表格格式打印關鍵字爲元組並且值爲元組的字典?
header1 header2 header3
(a, b) c d
但我得到了類型錯誤,'float'對象是不可迭代的。 mle prob和bi prob都是浮動的,它的值通常是0.0022323xxx。 如何解決這個錯誤?
非常感謝我真的很感激它。 –