python - 如何在 Zeppelin 中的 Python Pyspark 中打印粗体 - 以及使用 Zeppelin 中的 python-print-function 进行其他格式设置

标签 python pyspark apache-zeppelin

我在 Windows 桌面上使用 Zeppelin 中的 python 与 Zeppelin 安装在 Linux 机器上并且想要在中打印粗体内容 '%pyspark'-单元格。

print('\033[1m' + 'Hello' + '\033[0m')

在 Jupyter 环境中工作,但在 Zeppelin 中我只得到一个白色 白色背景上的字体不是粗体。 (我可以通过标记看到 文本。)

另外我可能会使用markdown语言。但那样我就不得不使用 分隔单元格并且无法使用 python 将文本合并 结果。

我还可以尝试什么?

最佳答案

在 Zeppelin 中,您可以使用这样的 html 来获取粗体文本:

print( '%html <b> hello </b>')

hello

只需在第一个引号后以“%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>')

对于:

important italic striked through low high

以下内容在 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>')

Heading 1

无序或有序列表:

print( '%html <ul>  <li>something</li>  <li>anything</li> </ul>  ')
print( '%html <ol>  <li>first</li>  <li>second</li> </ol>  ')
  • something
  • anything
  1. first
  2. second

链接:

 print('%html print <a href="https://www.stackoverflow.com">This is a link to stackoverflow.com</a> ')

This is a link to stackoverflow.com

将鼠标移到原始单词上时出现的缩写或信息文本。

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>')

Some examples for color codes

您也可以为背景着色:

print('%html <p style="background-color:rgb(255, 0, 0);">Background is red</p>')

关于python - 如何在 Zeppelin 中的 Python Pyspark 中打印粗体 - 以及使用 Zeppelin 中的 python-print-function 进行其他格式设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53682667/

相关文章:

python - scikit 学习 : update countvectorizer after selecting k best features

python - Tensorflow:如何在使用 tf.where() 时保持批量维度?

python - 如何在pyspark中打印具有特征名称的随机森林的决策路径?

python - 如何在 PySpark 数据框中添加变量/条件列

apache-spark - 为什么 Zeppelin-Spark 解释器没有挂载 Kubernetes 服务帐户

r - Zeppeling Docker镜像中缺少R解释器

python - 根据列中的值组合 Pandas 中的两行并创建一个新类别

python - 从 Locust 获取单个任务的统计信息

apache-spark - 使用 PySpark 分解数组值

apache-spark - .sample() 在 Spark 中使用固定的随机生成器种子返回不同的结果