change IPython Notebook JSON file encoding

ⅰ亾dé卋堺 提交于 2019-12-11 16:45:04

问题


By default, the JSON notebooks' encoding is ASCII:

{
 "cell_type": "heading",
 "level": 3,
 "metadata": {},
 "source": [
  "2.1.4. Nombre d'\u00e9l\u00e9ments: call/function/len"
 ]
},

Is it possible to change that into UTF-8?

{
 "cell_type": "heading",
 "level": 3,
 "metadata": {},
 "source": [
  "2.1.4. Nombre d'éléments: call/function/len"
 ]
},

I thought the option would be here, but I cannot figure out which one would make the trick.


回答1:


No it's not possible. You are mistaking the file encoding and the JSON encoding. If you actually look at the file encoding you will see that it is UTF-8 (in vim):

    {
     "cells": [
      {
       "cell_type": "markdown",
       "metadata": {
        "internals": {
    encoding? encoding=utf-8
There is no way to change json encoding, it does not make sens. The json parser you use shoudl convert automatically to/from whatever encoding you use in your programs.

[update] On current developpement version of IPython (future 3.0) the function responsible to write the file on disk now try to write it as UTF-8, so this should be fixed. Cf PR 7144. There is no way to configure back to plain ASCII though.



来源:https://stackoverflow.com/questions/27186073/change-ipython-notebook-json-file-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!