When you are getting started with SymPy it takes a while to keep straight the difference between SymPy objects and Python variables. Try to keep in mind that every variable is a Python variable and what you assign to it is up to you.
In line 6 you want to use variables x
and y
. You can look in the preceding lines to see that you never defined an x
(which would have to be on the lhs of an =
). This will remedy the situation:
>>> x, y = map(Symbol, list1)
It doesn't matter what is in list1
in terms of strings. They could even be ['a', 'b']
. Whatever they are they will be used to create SymPy symbols and they will be assigned to the Python variables x
and y
. They will then appear in the results of the equation that you are solving:
>>> list1 = list('ab')
>>> x, y = map(Symbol, list1)
>>> solve(Eq(x*2 - 5*x + 6 + y, 0), dict=True)
[{a: b/3 + 2}]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…