我有一行文字,我希望通过剪切结束并将其打印到下一行来使其更好看。我正在使用Tkinter并试图使Label使用3行而不是1,因为文本太长而无法显示。
label4Text.set("0.0.0.0 This subnet mask is non-routable as there is no network portion")
看起来像这样:
[0.0.0.0 This subnet mask is non-routable as there is no network portion]
我希望它看起来像这样:
[0.0.0.0
This subnet mask is non-routable
There is no network portion]
如何实现这一目标?
答案 0 :(得分:3)
使用\n
,例如:
label4Text.set("0.0.0.0\nThis subnet mask is non-routable\nas there is no network portion")
演示:
In [4]: s = "0.0.0.0 \nThis subnet mask is non-routable\nThere is no network portion"
In [5]: print s
0.0.0.0
This subnet mask is non-routable
There is no network portion