问题描述
在2个代码单元之间的Markdown单元中有一个表格,它是自动居中的,我希望像文本一样位于该单元的左侧。
这是代码:
Let's use the first row of `indices` to classify the 0th flower in `X_test`.
species | target
--- | ---
setosa | 0
versicolor | 1
virginica | 2
This cell prints the neighbor's position of closeness,index of the neighbor and that neighbor's `target` (Iris species).
解决方法
您可以使用Markdown
和display
来获得这样的结果。步骤如下:
from IPython.core.display import Markdown
m0 = Markdown('''
Let's use the first row of `indices` to classify the 0th flower in `X_test`.
''')
m1 = Markdown('''
|species | target |
|-----------|:------:|
|setosa | 0 |
|versicolor | 1 |
|virginica | 2 |
''')
m2 = Markdown('''
This cell prints the neighbor's position of closeness,index of the neighbor and that neighbor's `target` (Iris species).
''')
要显示,请执行
display(m0,m1,m2)