如何在 tkinter python 中获取 canvas.create_text() 文本值

How to get the canvas.create_text() text value in tkinter python

from tkinter import *

canvas = Canvas(width=500, height=100, bg="black")
typed_value = canvas.create_text(250, 50, text="5+7", font=("courier", 25, "bold"))

canvas.grid(column=0, row=0)

我想获取 typed_value 中文本的值 我使用了 get(1.0 End) 和 cget(1.0, End)

您可以使用

txt = canvas.itemcget(typed_value, 'text')