gpt4 book ai didi

python - html 输出中的整数(jupyter notebook)

转载 作者:太空狗 更新时间:2023-10-30 02:51:41 25 4
gpt4 key购买 nike

是否可以将 python 输出与 html 结合起来?我想在音符字符串中包含整数 i(如蓝色数字) Jupyter notebook

最佳答案

最简单的方法是构造字符串:

htmlOutput = '<h2>Note: '+ str(i) +'</h2>'

并在您的代码段中注入(inject)字符串:

from IPython.core.display import display, HTML

for i in range(10):
htmlOutput = '<h2>Note: '+ str(i) +'</h2>'
display(HTML(htmlOutput))

关于python - html 输出中的整数(jupyter notebook),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54858113/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com