这个错误是由于在 MathTex 中使用了非数学表达式引起的。MathTex 只能处理数学表达式,不能处理普通的文本。要解决这个问题,你可以将非数学表达式放在 Text 对象中,而不是 MathTex 对象中。例如,将 "钱" 和 "里" 放在 Text 对象中,将数学表达式放在 MathTex 对象中。修改后的代码如下所示:\n\npython\nfrom manim import *\n\nclass CircleToSquare(Scene):\n def construct(self):\n equation = Text(\"定义\", \"钱\", \"里\")\n self.play(Write(equation))\n self.wait()\n\n self.play(Write(equation))\n self.wait()\n\nif __name__ == \"__main__\":\n scene = CircleToSquare()\n scene.render()\n\n\n这样修改后,就不会再出现 "ValueError: could not convert string to float: '钱'" 的错误了。

Manim 中 MathTex 对象处理非数学表达式错误解决方法

原文地址: https://www.cveoy.top/t/topic/qzvl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录