小编Rea*_*ess的帖子

Sympy:如何解析诸如“2x”之类的表达式?

            #split the equation into 2 parts using the = sign as the divider, parse, and turn into an equation sympy can understand
            equation = Eq(parse_expr(<input string>.split("=")[0]), parse_expr(<input string>.split("=")[1]))
            answers = solve(equation)
            #check for answers and send them if there are any
            if answers.len == 0:
                response = "There are no solutions!"
            else:
                response = "The answers are "
                for answer in answers:
                    response = response + answer + ", "
                response = response[:-2]
        await self.client.send(response, message.channel)
Run Code Online (Sandbox Code Playgroud)

我试图制作一个使用 sympy 来解决代数的不和谐机器人,但我一直遇到上述实现的错误。有人可以帮忙吗?

但是对于输入 …

sympy python-3.x

5
推荐指数
1
解决办法
297
查看次数

标签 统计

python-3.x ×1

sympy ×1