Traceback (most recent call last): File "D:/PyCharm 2021/新建文件夹/数据转成可视化.py", line 105, in <module> map_1.render("全国疫情分布图.html") File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pyecharts\charts\base.py", line 92, in render self._prepare_render() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pyecharts\charts\base.py", line 116, in _prepare_render self.json_contents = self.dump_options() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pyecharts\charts\base.py", line 77, in dump_options json.dumps(self.get_options(), indent=4, default=default, ignore_nan=True) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\simplejson\__init__.py", line 381, in dumps return cls( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\simplejson\encoder.py", line 300, in encode chunks = list(chunks) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\simplejson\encoder.py", line 714, in _iterencode for chunk in _iterencode_dict(o, _current_indent_level): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\simplejson\encoder.py", line 668, in _iterencode_dict for chunk in chunks: File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\simplejson\encoder.py", line 735, in _iterencode for chunk in _iterencode(o, _current_indent_level): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\simplejson\encoder.py", line 714, in _iterencode for chunk in _iterencode_dict(o, _current_indent_level): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\simplejson\encoder.py", line 668, in _iterencode_dict for chunk in chunks: File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\simplejson\encoder.py", line 544, in _iterencode_list for chunk in chunks: File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\simplejson\encoder.py", line 620, in _iterencode_dict key = _stringify_key(key) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\simplejson\encoder.py", line 580, in _stringify_key raise TypeError('keys must be str, int, float, bool or None, ' TypeError: keys must be str, int, float, bool or None, not builtin_function_or_method
时间: 2023-07-30 09:08:55 浏览: 397
Mac下anaconda中Spyder打开报错Traceback(most recent call last)…问题
5星 · 资源好评率100%
这个错误是由于在使用pyecharts库时,传入了一个非法的键(key),导致无法将其转换为JSON格式。根据错误信息,这个键的类型是内置函数或方法(builtin_function_or_method),而JSON只支持字符串(str)、整数(int)、浮点数(float)、布尔值(bool)或None类型的键。
要解决这个问题,你需要检查代码中使用pyecharts库的部分,确认传入的键是合法的类型。如果有使用内置函数或方法作为键的情况,需要修改代码,将其转换为合法类型的键,例如字符串。
如果你无法确定出现问题的具体代码,请提供更多关于你使用pyecharts库的代码片段,我可以帮你进一步分析和解决问题。
阅读全文