[英]Continue printed text to next line in Python
我有一排文字,我想通過剪掉結尾並將其打印到下一行來使其看起來更好。 我正在使用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]
如何做到這一點?
使用\\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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.