【问题标题】:How can I insert text and variables into a text box in Python tkinter without elements being contained by {}如何在 Python tkinter 的文本框中插入文本和变量,而 {} 不包含元素
【发布时间】:2020-07-24 06:55:07
【问题描述】:

我正在尝试在 tkinter 中使用文本小部件来显示我的代码的输出。

sequence = ("This peptide contains ", len(Peptide), "total residues", "\n")
text.insert("current", sequence)

这似乎有效,除了打印时, elements are separated by {}.

我希望输出不包含这些括号,并读为:“此肽包含 17 个总残基”。有没有办法做到这一点?

谢谢

【问题讨论】:

  • insert 方法需要一个字符串,而不是一个元组。

标签: python tkinter printing insert text-widget


【解决方案1】:

这是因为sequencetuple。尝试将其更改为

sequence = "This peptide contains {} total residues\n".format(len(Peptide))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-22
    • 2012-08-29
    • 2017-01-10
    • 1970-01-01
    • 2013-11-08
    • 1970-01-01
    • 1970-01-01
    • 2012-09-01
    相关资源
    最近更新 更多