The question here is how to convert a unicode string into a latex output as a latex editor/compiler system would do. The best package for that is pylatexenc
To answer your question:
from pylatexenc.latex2text import LatexNodes2Text
from pylatexenc.latexencode import UnicodeToLatexEncoder
# To convert some latex unicode input to actual latex output
in_expr_unicode = r"""5div2imes(68+87)-10div4"""
out_latex = LatexNodes2Text().latex_to_text(in_expr_unicode)
print(' The math formula: ', out_latex)
# To convert the latex string back to unicode printable string (for use in some latex editor)
u = UnicodeToLatexEncoder(unknown_char_policy='replace')
print('The latex editor input was: ', u.unicode_to_latex(out_latex))
The output would be:
The math formula: 5÷2×(68+87)-10÷4
The latex editor input was: 5{extdiv}2{exttimes}(68+87)-10{extdiv}4
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…