python 显示乘法符号和除法符号(python print multiplication symbol and division symbol)


 

python中运算时用的乘法和除非符号是 * 和 % / 之类的,最近需要用到 ✖ 和 ➗ 两个字符串显示数据,找到了可实现的资料,分享给大家。

参考资料:https://stackoverflow.com/questions/65607397/how-do-i-display-the-multiplication-and-division-symbol-using-pytexit

安装:pip install pylatexenc

代码实现:

In [11]: from pylatexenc.latex2text import LatexNodes2Text In [12]: mul_symbol = r"""\times""" In [13]: div_symbol = r"""\div""" In [14]: mul_symbol Out[14]: '\\times' In [15]: div_symbol Out[15]: '\\div' In [16]: mul_symbol_text = LatexNodes2Text().latex_to_text(mul_symbol) In [17]: div_symbol_text = LatexNodes2Text().latex_to_text(div_symbol) In [18]: mul_symbol_text Out[18]: '×' In [19]: div_symbol_text Out[19]: '÷' In [20]: "6" + div_symbol_text + "3 = 2" Out[20]: '6÷3 = 2'

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM