为什么jupyter笔记本会在ipynb文件结尾添加很长的^ @符号列表?(Why does jupyter notebook append long list of ^@ symbols to en

编程入门 行业动态 更新时间:2024-10-22 19:34:09
为什么jupyter笔记本会在ipynb文件结尾添加很长的^ @符号列表?(Why does jupyter notebook append long list of ^@ symbols to end of ipynb file?)

大约一年前,我注意到当我试图打开我保存在大学服务器上的python笔记本时,我得到了一个“笔记本看起来不是JSON”的错误。 起初,我感到震惊和沮丧的是,我所有的辛勤工作都已经永远消失了,但是当我在emacs中检查文件时,我发现除了生命的结尾包含了很长的^ @符号列表之外,它们都在那里。 JSON解释器(下面的例子)。

只需删除这些^ @符号即可恢复文件。 从那以后每次我收到这个JSON错误(经常这样)我只是打开emacs并删除符号,但它变得很烦人。

任何人都可以向我解释为什么会发生这种情况并且可以预防吗? 据我所知,这只发生在我从我的个人笔记本电脑(MacBook Pro OS X 10.12.6)通过smb连接到的服务器上处理ipynb文件时。 当ipynb文件存储在本地时,它永远不会发生。 我只是喜欢在服务器上工作,因为一切都是自动备份的,有时我使用不同的计算机,所以我总是可以访问我的文件。

About a year ago I noticed that when I tried opening my python notebooks I had saved on a university server I got a “Notebook does not appear to be JSON” error. At first I was shocked and dismayed that all my hard work was gone forever, but when I inspected the file in emacs I saw that it was all there except that the end of the life contained a long list of ^@ symbols, which confused the JSON interpreter (example below).

Simply deleting these ^@ symbols restored the file. Since then every time I get this JSON error (which is fairly often) I just open emacs and delete the symbols, but it’s getting annoying.

Can anyone explain to me why this happens and can it be prevented? As far as I can tell, this only happens when I work on ipynb files from a server that my personal laptop (MacBook Pro OS X 10.12.6) is connected to via smb. It never happens when the ipynb files are stored locally. I just prefer working from the server because everything is automatically backed up and sometimes I use different computers, so I always have access to my files.

最满意答案

该文件已损坏。 ^@表示ASCII NUL字节。 简单来说,文件被扩展到更大的尺寸; 元数据被刷新到磁盘,但是当计算机(意外)关闭或操作系统崩溃或USB驱动器被移除时,实际内容仍保留在缓存中。

即在你的情况下,你可能失去了对该文件的最新编辑。

The file is corrupted. The ^@ means the ASCII NUL byte. Simply what has happened is that the file was extended to some larger size; the metadata was flushed to disk, but the actual contents remained in the cache when the computer (accidentally) shut down or the operating system crashed, or the USB drive was removed.

I.e. in your case, you probably did lose your latest edit to this file.

更多推荐

本文发布于:2023-07-16 13:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1129000.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   很长   结尾   符号   笔记本

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!