The unicode for the plus and minus symbol (±) is u"\±"
. I can't seem to be able to write submit this unicode with f-string in a single line. See below.
>>> print( f'{u"\u00B1"}2 stddev' )
SyntaxError: f-string expression part cannot include a backslash
Instead, I have to do this:
>>> plusminus = u"\u00B1"
>>> print( f'{plusminus}2 stddev' )
±2 stddev
I would like to write it in a single line. How do I do this with f-string?
For non f-string, I can do this:
>>> print( '\u00B12 stddev' )
±2 stddev
这会做print( f'\±2 stddev' )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.