Python 如何更改Jupyter笔记本中HTML显示表格的背景色

Python 如何更改Jupyter笔记本中HTML显示表格的背景色,python,jupyter-notebook,jupyter,Python,Jupyter Notebook,Jupyter,我使用函数display(HTML(HTML字符串))在笔记本中显示HTML格式的表。然而,尝试一些css来改变表格的背景颜色是不被尊重的。这是我的代码的一个小漏洞: rownum = 1 # make this table yellow source = '<table bgcolor="yellow"><tr><th>Number</th><th>Instance Type</th><th>Total Cos

我使用函数display(HTML(HTML字符串))在笔记本中显示HTML格式的表。然而,尝试一些css来改变表格的背景颜色是不被尊重的。这是我的代码的一个小漏洞:

rownum = 1
# make this table yellow
source = '<table bgcolor="yellow"><tr><th>Number</th><th>Instance Type</th><th>Total Cost</th>' \
    '<th>Number of Instances</th></tr>'

for k in keys: 
    source += "<tr><td>%d</td><td>%s</td><td>$%0.2f</td><td>%d</td></tr>" % \
          (rownum,resultsTable2[k]["itype"],k,resultsTable2[k]["num"])
    rownum += 1

source += '</table>'
display(HTML(source))
rownum=1
#把这张桌子弄黄
来源='NumberInstance类型总成本'\
“实例数”
对于k in键:
source+=%d%s$%0.2f%d%\
(rownum,resultsTable2[k][“itype”],k,resultsTable2[k][“num”])
rownum+=1
来源+=''
显示(HTML(源代码))
输出如下所示:

版本详细信息

笔记本服务器的版本为4.4.1,运行于: Python 2.7.12(默认,2016年9月28日,18:41:32) [GCC 4.2.1兼容苹果LLVM 8.0.0(clang-800.0.38)]

Firefox 53.0.3在OS X Sierra上

bummer-display(HTML())无法通过PDF导出。