문제

from sympy import *

x, alpha = symbols('x alpha')

latex(alpha/x)

Out[1]: '\\frac{\\alpha}{x}'

That doesn't work in latex. What do I do to get the proper output, i.e.: '\frac{\alpha}{x}' ?

도움이 되었습니까?

해결책

That is correct an output (repr escape some characters, \ in this case.). Try to print it.

>>> x = '\\frac{\\alpha}{x}'
>>> x
'\\frac{\\alpha}{x}'
>>> print(x)
\frac{\alpha}{x}

다른 팁

Got it!

Write:

print latex(alpha/x)
\frac{\alpha}{x}

Sorry about bothering you guys!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top