简体   繁体   English

更改IPython Notebook JSON文件编码

[英]change IPython Notebook JSON file encoding

By default, the JSON notebooks' encoding is ASCII: 默认情况下,JSON笔记本的编码为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? 是否可以将其更改为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. 我以为可以在这里进行选择 ,但是我无法弄清楚哪个会成功。

No it's not possible. 不,这不可能。 You are mistaking the file encoding and the JSON encoding. 您错误地使用了文件编码和JSON编码。 If you actually look at the file encoding you will see that it is UTF-8 (in vim) 如果您实际查看文件编码,则会看到它是UTF-8(在vim中) :

{
     "cells": [
      {
       "cell_type": "markdown",
       "metadata": {
        "internals": {
    encoding? encoding=utf-8
There is no way to change json encoding, it does not make sens. 没有办法改变json编码,它没有意义。 The json parser you use shoudl convert automatically to/from whatever encoding you use in your programs. 您使用shoudl的json解析器会自动与程序中使用的任何编码进行转换。

[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. [更新]在IPython的当前开发版本(将来的3.0版)上,负责将文件写入磁盘的函数现在尝试将其写入UTF-8,因此应予以解决。 Cf PR 7144 . 参见PR 7144 There is no way to configure back to plain ASCII though. 但是,无法配置回纯ASCII。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM