Printing subscript in python

后端 未结 5 557
逝去的感伤
逝去的感伤 2020-12-03 01:53

In Python 3.3, is there any way to make a part of text in a string subscript when printed?

e.g. H₂ (H and then a subscript 2)

5条回答
  •  情深已故
    2020-12-03 02:37

    By using this code you can use alphabets on the superscript and subscript In This code format() is Function and in Format function ('\unicode')

    By using this table (Unicode subscripts and superscripts on Wikipedia) you can give suitable unicode to the suitable one

    you can use superscript and sub script

    "10{}".format('\u00B2')  # superscript 2
    

提交回复
热议问题