80546
文字列'x-y'をx-yに変換する方法を教えて下さい。

```

    from sympy import *
    var('x y')
    print(type( x-y ),( x-y ).subs(x,0.0))
    print(type('x-y'))
    print(type('x-y'),('x-y').subs(x,0.0))
    # <class 'sympy.core.add.Add'> -y
    # <class 'str'>
    # Traceback (most recent call last):
    #   File "C:/Users/xxx/PycharmProjects/pythonProject/main.py", line 5, in <module>
    #     print(type('x-y'),('x-y').subs(x,0.0))
    # AttributeError: 'str' object has no attribute 'subs'
    
```
CC BY-SA 4.0
2021-08-01T02:38:59.563
80511
2021-08-02T11:33:48.963
2021-08-01T04:22:33.800
3060
47526
question
python sympy
sympyで「AttributeError: 'str' object has no attribute 'subs'」がでました。
```

    from sympy import *
    var('x y')
    print("# ",type( x-y ),( x-y ).subs(x,0.0))
    print("# ",type('x-y'))
    print("# ",type(sympify('x-y')),sympify('x-y').subs(x,0.0))
    #  <class 'sympy.core.add.Add'> -y
    #  <class 'str'>
    #  <class 'sympy.core.add.Add'> -y
    
```
CC BY-SA 4.0
2021-08-02T11:33:48.963
80546
2021-08-02T11:33:48.963
47526
80511
answer