假设我在 python shell 中创建了一些变量。我想做这样的事情:
>>> animal="Cat"
>>> age="2"
>>> weight="3.8"
>>> name="Kitty"
>>> env.saveTo("./Cat.json")
>>> env.clear()
>>> env.loadFrom("./Cat.json")
这可能吗?我正在使用 xonsh
。
最佳答案
我使用了xonsh
$ xonsh
$ animal="Cat"
$ age="2"
$ weight="3.8"
$ name="Kitty"
$ history > Cat
$ exit
$ xonsh
$ source Cat
哈!最后,我避免了 jupyter notebook
。
关于python - 如何在 python shell 中将所有变量写入 JSON 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48944382/