【求助】python中的print 怎麼打印unicode碼

import cmath

import math

import sys

import io


print("ax\N{SUPERSCRIPT TWO} + bx +c =0")

----運行的時候會報錯

print("ax\N{SUPERSCRIPT TWO} + bx +c =0")

UnicodeEncodeError: 'gbk' codec can't encode character '\xb2' in position 2: illegal multibyte sequence


在網上查找添加了後

sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True)

打印爲:

ax? + bx +c =0


怎樣纔會正確的顯示

ax2 + bx +c =0

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章