如何将dsolve()的输出转换为字符或字符串?我想使用输出并在循环中使用它来插入一些字符?
这是我的代码:
from sympy.interactive import printing
import numpy as np
from scipy.integrate import odeint
printing.init_printing(use_latex=True)
from sympy import*
import sympy as sp
import matplotlib.pyplot as plt
from sympy.integrals import laplace_transform
from sympy.integrals import inverse_laplace_transform
from sympy.abc import s,t
from colorama import Fore
import math
ti=sp.symbols('ti');
y1=sp.Function('y1');
dif=sp.Eq(10*y1(ti).diff(ti,ti)+(1000*y1(ti))-4250,0); # ODE
display(dif);
res=sp.dsolve(dif,ics={y1(0):1.25,sp.diff(y1(ti),ti).subs(ti,0):0}); # INITIAL CONDITION
display(res);
print(len(res));
for c in res:
print(c);
File "<ipython-input-71-6aa9e3d9c262>", line 1, in <module>
runfile('C:/Users/IPC/Desktop/Python Files/Text backup Files/untitled1.py', wdir='C:/Users/IPC/Desktop/SHRAVAN/Python Books/Python Files/Text backup Files')
File "C:\Users\IPC\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\IPC\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/IPC/Desktop/Python Files/Text backup Files/untitled1.py", line 23, in <module>
**print(len(res));
*TypeError: object of type 'Equality' has no len()
for c in res:
TypeError: 'Equality' object is not iterable*****
那么如何将相等对象转换为字符串?