如何将计算值打印到消息框中?

How to print a calculated value into a message box?

我正在尝试打印存储在“余数”中的计算值并将其打印到消息框中。但是,我收到一条错误消息 messagebox.showinfo('Alert','Current levels dropped by',余数) TypeError: showinfo() 接受 0 到 2 个位置参数,但给出了 3 个。我想知道是否有人可以帮助我,非常感谢。代码如下图

quotient = c1/800
percent = quotient * 100
remainder = 100 - percent
alarmlight = my_canvas.create_oval(50, 50, 100, 100, fill='green')
my_canvas.itemconfig(alarmlight, fill="red") #Fill the circle with red
window = Tk()
window.eval('tk::PlaceWindow %s center' % window.winfo_toplevel()) #window will be infront of all windows
window.withdraw()
messagebox.showinfo('Alert','Current levels dropped by',remainder)

你最好的选择是使用 f-strings

messagebox.showinfo('Alert',f'Current levels dropped by {remainder}')