ValueError matplotlib display text must have all code points 128 or use Unicode strings

简介: ValueError matplotlib display text must have all code points 128 or use Unicode strings

错误问题ValueError: matplotlib display text must have all code points < 128 or use Unicode strings


错误原因:在使用matplotlib进行图表展示时,如果需要在图表上添加中文,可能会报字符类型的值错误。


解决办法:重新调用系统,修改默认的字符类型。


import sys
reload(sys)
sys.setdefaultencoding('utf-8')


说明:一般在我们写程序的过程中,经常会遇到这种字符类型错误,可以尝试从了解系统的字符类型和编译器等字符类型是否统一入手,如果有中文英文,尽可能使用utf-8.

目录
相关文章
|
4月前
|
Python
【Python】已解决:re.error: bad escape \z at position 4
【Python】已解决:re.error: bad escape \z at position 4
298 0
|
4月前
|
数据处理 开发者 Python
【Python】已解决:ValueError: Length mismatch: Expected axis has 5 elements, new values have 4 elements
【Python】已解决:ValueError: Length mismatch: Expected axis has 5 elements, new values have 4 elements
279 9
|
4月前
|
编解码 测试技术 Python
【Python】已解决:UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1: ordinal not i
【Python】已解决:UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1: ordinal not i
723 1
|
4月前
|
编解码 开发者 Python
【Python】已解决:UnicodeEncodeError: ‘gbk’ codec can’t encode character ‘\u0157’ in position 1: illegal m
【Python】已解决:UnicodeEncodeError: ‘gbk’ codec can’t encode character ‘\u0157’ in position 1: illegal m
54 1
|
4月前
|
编解码 开发者 Python
【Python】已解决:SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: t
【Python】已解决:SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: t
435 0
|
4月前
|
编解码 开发者 Python
【Python】已解决:UnicodeEncodeError: ‘utf-8’ codec can’t encode characters in position 42-43: surrogates
【Python】已解决:UnicodeEncodeError: ‘utf-8’ codec can’t encode characters in position 42-43: surrogates
374 0
|
4月前
|
数据处理 开发者 索引
【Python】已解决:FutureWarning: The frame.append method is deprecated and will be removed from pandas in
【Python】已解决:FutureWarning: The frame.append method is deprecated and will be removed from pandas in
167 0
|
Python
Python报错ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Python报错ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
1567 1
|
索引 Python
Python报错:IndexError: index 0 is out of bounds for axis 0 with size 0
Python报错:IndexError: index 0 is out of bounds for axis 0 with size 0
368 0
|
存储 JSON Linux
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (ch
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (ch