[英]Curly braces showing in text in Python
這是我正在使用的代碼的一部分-問題在下面詳述。 我正在Mint Linux Nadia上使用Python 3.2和tkinter創建一個簡單的儲蓄計算器。 歡迎指教! 謝謝湯姆
Button(self,
text = "Click for savings calculations",
command = self.show_result
).grid(row = 6, column = 0, sticky = W)
self.result_txt = Text(self, width = 75, height = 10, wrap = WORD)
self.result_txt.grid(row = 7, column = 0, columnspan = 4)
def show_result(self):
curacct = int(self.curacct_ent.get())
isa = int(self.isa_ent.get())
av = int(self.av_ent.get())
avu = int(self.avu_ent.get())
a = int(curacct + isa)
b = int(av*avu)
result = "Your savings total is £", (a)
result += "and the A shares are worth £", (b)
result += "Your total savings is £", (a+b)
self.result_txt.delete(0.0, END)
self.result_txt.insert(0.0, result)
# main
root = Tk()
root.title("Savings Calculator")
app = Application(root)
root.mainloop()
當我運行該程序時,文本可以很好地打印,但是在文本周圍包含花括號:{您的儲蓄總額為£} 10 {而A股的價值為£} 25 {您的儲蓄總額為£} 35
我不明白為什么會有花括號,但我希望它們消失。 有人知道我該怎么做嗎? 順便說一句,到目前為止,我只是一個學習python並熱愛它的愛好者。 我只包含了我認為相關的代碼部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.