python - 如何在 python shell 中将所有变量写入 JSON 文件

标签 python python-3.x shell xonsh

假设我在 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/

相关文章:

python - 大类对性能有显着影响吗?

shell - 为什么 shell case 语句中的第一个模式不能是多个模式?

shell - 在shell脚本中使用hadoop比较两个值

python - 使用python限制excel文件中的工作表数量

python - 在条件下使用 Python 解析/提取嵌套的 JSON 数据

python , Pandas : write content of DataFrame into text File

python - 更改列表中的字符 Python Flask

perl - 相同行之间的文本提取

python - 比较 int 变量

python - 我下载音频文件,但采用 m3u8 格式。如何转换成mp3?