问题
I use cyrillic symbols in my Jupyter notebooks.
In NoteBook №1 I run NoteBook №2.
%run ./NB2.ipynb
In NoteBook №2 I write in some txt file.
TestText = open('C:\\TRASH\\test_text.txt', 'w')
a = 'Иридий' #Iridium
TestText.write(a+'\n')
TestText.close()
And when NB1 starts I get UnicodeDecodeError.
...can't decode byte 0x98
Full output is there: http://collabedit.com/tcev6
Briefly, Nbformat library call core.reads which, in its turn, read NB2 in win-1251 encoding. That's why first 'И' is the problem.
Is there a regular way to choose the encoding for reading second notebook?
回答1:
pls ref:
https://nbviewer.jupyter.org/gist/minrk/5491090/analysis.ipynb
change "with io.open(nbfile) as f:"
to "with io.open(nbfile,encoding="utf-8") as f:"
来源:https://stackoverflow.com/questions/43915006/encoding-error-in-jupyter-when-run-another-notebook