更改IPython Notebook JSON文件编码 [英] change IPython Notebook JSON file encoding

查看:194
本文介绍了更改IPython Notebook JSON文件编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,JSON笔记本的编码为ASCII:

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"
 ]
},

是否可以将其更改为UTF-8?

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.

推荐答案

否.您错误地使用了文件编码和JSON编码. 如果您实际查看文件编码,您会发现它是UTF-8(在vim中):

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

没有办法改变json编码,它没有意义.您使用shoudl的json解析器会自动与程序中使用的任何编码进行转换.

[更新]在IPython的当前开发版本(将来的3.0版)上,负责将文件写入磁盘的函数现在尝试将其写入UTF-8,因此应予以解决.参见 PR 7144 .但是,无法将其配置回纯ASCII.

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.

这篇关于更改IPython Notebook JSON文件编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆