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

How to print bold in Python Pyspark in Zeppelin - and other formatting with the python-print-function in Zeppelin

我在装有 Zeppelin 的 windows 桌面上使用 Zeppelin 中的 python 安装在 Linux 机器上,想打印一些粗体的东西 '%pyspark'-cell.

print('3[1m' + 'Hello' + '3[0m')

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

另外我可能会用markdown语言。但那时我将不得不使用 单独的单元格,无法将文本与 python 合并 结果。

我还可以尝试什么?

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

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

hello

只需在第一个引号之后以“%html”开头,然后您可以使用 html 语法直到第二个引号。

对于那些还没有经常使用 HTML 的人,这里还有一些 HTML-basics 以及如何在 %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.whosebug.com">This is a link to whosebug.com</a> ')

This is a link to whosebug.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 颜色 space,其中 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>')