GithubHelp home page GithubHelp logo

Comments (3)

iseekwonderful avatar iseekwonderful commented on August 20, 2024 7

这个应该是编码问题,因为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'))

修改后的_htmlplot函数

    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.

xrjervis avatar xrjervis commented on August 20, 2024

同问

from echarts-python.

haliluyaya avatar haliluyaya commented on August 20, 2024

照这样改了,还是会报错。UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 250: illegal multibyte sequence

from echarts-python.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.