python - 调用 tabulate TypeError: 'tuple' object is not callable 后出现此错误
问题描述
from tabulate import tabulate
mydata= [('29.16', '30.10', '1', '7')
('20.83', '17.60', '2', '5')
('12.50', '12.49', '3', '3')
('8.33', '9.69', '4', '2')
('8.33', '7.92', '5', '2')
('8.33', '6.69', '6', '2')
('0', '5.80', '7', '0')
('8.33', '5.12', '8', '2')
('4.17', '4.58', '9', '1')]
header= [('Actual Value', 'Predicted value', 'Leading Digit value', 'Count')
]
print(tabulate(mydata, headers=header))
解决方案
您的输入有一些错误。您在上面的评论中缺少commas
( ,
) 。mydata
要解决解决方案,您应该更改
mydata= [('29.16', '30.10', '1', '7')
('20.83', '17.60', '2', '5')
('12.50', '12.49', '3', '3')
('8.33', '9.69', '4', '2')
('8.33', '7.92', '5', '2')
('8.33', '6.69', '6', '2')
('0', '5.80', '7', '0')
('8.33', '5.12', '8', '2')
('4.17', '4.58', '9', '1')]
至
mydata= [('29.16', '30.10', '1', '7'),
('20.83', '17.60', '2', '5'),
('12.50', '12.49', '3', '3'),
('8.33', '9.69', '4', '2'),
('8.33', '7.92', '5', '2'),
('8.33', '6.69', '6', '2'),
('0', '5.80', '7', '0'),
('8.33', '5.12', '8', '2'),
('4.17', '4.58', '9', '1')]
推荐阅读
- ruby-on-rails - Rails 用守卫替换 if/elseif 块
- javascript - Vue.js - 使用外部脚本而不是导入的脚本
- google-apps-script - 谷歌脚本将没有 URL 的图像插入到谷歌表格
- java - 如何解决“索引越界错误”?
- python-3.x - Jupyter 安装环境
- reactjs - 材质 UI 禁用复选框悬停
- css - position: fixed 不占空间,下面怎么加?
- django - 无法使用 Django 在 HTML 中插入类别标题
- javascript - 如何制作显示在列表中最后一个警报元素中的扩展?
- php - 我在 Laravel 8 中使用 rtconner/laravel-tagging 按标签获取有问题