【问题标题】:How to display variables on a new line python如何在新行python上显示变量
【发布时间】:2014-07-03 08:18:37
【问题描述】:

我正在尝试使用 tkinter 制作一个小应用程序。我的部分代码如下所示:

weatherinfo = str(z + y + x + w + v + u)
info = Label(mainwindow, bg = 'magenta', height = 8, width = 14, text = weatherinfo, font = ('arial', 20, 'normal'))
info.pack(side = LEFT,padx = 20)

我试图让每个变量(x、y 等)显示在名为 info 的标签中的新行上。但是,它们都打印在一行上。我该如何解决这个问题?

谢谢:)

【问题讨论】:

  • 我曾尝试过类似的方法,但没有成功,但您的版本有效。已解决,非常感谢。
  • 酷。我会将我的评论转换为答案,以便接受它并结束问题。

标签: python python-2.7 tkinter


【解决方案1】:

您是否尝试将换行符插入到 weatherinfo 字符串中?

weatherinfo = '\n'.join([z, y, x, w, v, u])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-20
    • 2016-09-28
    • 1970-01-01
    • 2023-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-13
    相关资源
    最近更新 更多