Comments (3)
这个应该是编码问题,因为windows下默认编码是gbk,所以会报错。
如果是3.5的话,在#94行加上encoding='utf8'
with open(os.path.join(os.path.dirname(__file__), 'plot.j2'), encoding='utf8') as f:
但是还会报
TypeError: a bytes-like object is required, not 'str'
在#105编码成bytes即可
fobj.write(self._html().encode('utf8'))
修改后的_html
和plot
函数
def _html(self):
with open(os.path.join(os.path.dirname(__file__), 'plot.j2'), encoding='utf8') as f:
template = f.read()
return template.replace('{{ opt }}', json.dumps(self.json, indent=4))
def plot(self, persist=True):
"""
Plot into html file
:param persist: persist output html to disk
"""
with tempfile.NamedTemporaryFile(suffix='.html', delete=not persist) as fobj:
fobj.write(self._html().encode('utf8'))
fobj.flush()
webbrowser.open('file://' + os.path.realpath(fobj.name))
persist or raw_input('Press enter for continue')
from echarts-python.
同问
from echarts-python.
照这样改了,还是会报错。UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 250: illegal multibyte sequence
from echarts-python.
Related Issues (17)
- 中文乱码 HOT 7
- 怎么设置 "yAxis": {} 呢? HOT 1
- sample文件夹里的例子可以在win7下运行吗
- UnicodeDecodeError
- How to set the width HOT 1
- 怎么将figure 保存成矢量图
- python3 调用echart.plot()会报错 HOT 3
- 求Tree函数例子,画树状图
- 请问下楼主如何生成本地的json文件呢?
- legent not shown HOT 1
- Create samples for providing chart-code mapping
- Complete all options.
- Bad link addresses in readme HOT 1
- Could not be installed with pip HOT 1
- How to use echart in python?
- Add IPython notebook inline plot HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from echarts-python.