python - 如何在 Zeppelin 中的 Python Pyspark 中打印粗体 - 以及在 Zeppelin 中使用 python-print-function 的其他格式
问题描述
我在 Windows 桌面上使用 Zeppelin 中的 python,Zeppelin 安装在 Linux 机器上,并希望在“%pyspark”单元格中打印一些粗体。
print('\033[1m' + 'Hello' + '\033[0m')
在 Jupyter 环境中工作,但在 Zeppelin 中,我只是在白色背景上得到一个不粗体的白色字体。(我可以通过标记文本来看到这一点。)
此外,我可能会使用降价语言。但随后我将不得不使用单独的单元格,并且无法将文本与 python 结果结合起来。
我还能尝试什么?
解决方案
在 Zeppelin 中,您可以像这样使用 html 来获取粗体文本:
print( '%html <b> hello </b>')
你好
只需在第一个引号后以“%html”开头,然后您可以使用 html 语法直到第二个引号。
对于那些还没有大量使用 HTML 的人,这里有一些更多的 HTML 基础知识以及如何在 %pyspark - Zeppelin 单元中使用它们:
其他文字样式
print('%html <strong>important</strong>')
print('%html <i>italic</i>')
print('%html <del>striked through</del>')
print('%html <sub>low</sub>')
print('%html <sup>high</sup>')
为了:
重要的 斜体
击穿低 高
以下在 Zeppelin 中也可以正常工作,但我现在无法展示它:
print('%html <ins>underlined</ins>')
print('%html <mark>marked</mark>')
print('%html <small>small</small>')
您可以使用 h1, h2,...,h6 作为标题:
print('%html <h1>Heading 1</h1>')
标题 1
无序或有序列表:
print( '%html <ul> <li>something</li> <li>anything</li> </ul> ')
print( '%html <ol> <li>first</li> <li>second</li> </ol> ')
- 某物
- 任何事物
- 第一的
- 第二
链接:
print('%html print <a href="https://www.stackoverflow.com">This is a link to stackoverflow.com</a> ')
将鼠标移到原始单词上时出现的缩写或信息文本。
print('%html <p><abbr title="Hypertext Markup Language">HTML</abbr> is the standard markup language for creating web pages and web applications.</p>')
您可以在 Zeppelin 中尝试一下。
文字颜色
例如,基于 rgb 颜色空间,其中 r,g,b 是颜色中红色、绿色和蓝色的数量:
print('%html <p style="color:rgb(255, 0, 0);">red</p>')
print('%html <p style="color:rgb(0, 255, 0);">green</p>')
print('%html <p style="color:rgb(0, 0, 255);">blue</p>')
您也可以为背景着色:
print('%html <p style="background-color:rgb(255, 0, 0);">Background is red</p>')
推荐阅读
- c++ - 从复制构造函数调用构造函数
- core-image - componentMax CIBlendKernel 与lighten 或lighterColor 有何不同?
- javascript - 单击另一个页面时,导航栏活动不会改变
- python - cx_freeze [Errno 2] 没有这样的文件或目录
- python - 在Apache中加载Python时必须添加执行权限?
- dataframe - Julia:防止在函数执行后打印数据框
- extjs - 清除组合框值
- json - 当我尝试在 Spring Boot 应用程序中将自定义错误传递给客户端时发生异常
- java - 使用 SML 确定两个不同本体之间概念的语义度量
- php - 有没有办法使用 CI (HMVC) 中的路由重定向视图?