plus/minus operator for python ±

前端 未结 7 647
遇见更好的自我
遇见更好的自我 2020-12-31 02:20

I am looking for a way to do a plus/minus operation in python 2 or 3. I do not know the command or operator, and I cannot find a command or operator to do this.

Am I

7条回答
  •  情书的邮戳
    2020-12-31 02:59

    If you happen to be using matplotlib, you can print mathematical expressions similar as one would with Latex. For the +/- symbol, you would use:

    print( r"value $\pm$ error" )
    

    Where the r converts the string to a raw format and the $-signs are around the part of the string that is a mathematical equation. Any words that are in this part will be in a different font and will have no whitespace between them unless explicitly noted with the correct code. This can be found on the relavent page of the matplotlib documentation.

    Sorry if this is too niche, but I stumbeled across this question trying to find this very answer.

提交回复
热议问题