在 python 中获取大括号之间的文本

Get text between curly brackets in python

我正在尝试从该文本的大括号中获取文本:

circle(265.17373,-53.674312,1") # text={1}
circle(265.17373,-53.674312,2") # text={2}

对于括号之间的内容,我使用这个和那个有效

array = np.append(array, np.array([float(x) for x in re.findall(r"\d+(?:\.\d+)?", line)]))

但我还想要大括号内的文字。

array2 = np.append(array2, np.array([float(x) for x in re.findall(r"/\{([^}]+)\}/", line)]))

但这并没有回报任何东西。

您需要删除第二行代码中的正斜杠。

array2 = np.append(array2, np.array([float(x) for x in re.findall(r"\{([^}]+)\}", line)]