>> age="2" >>> weight="3.8" >>> name="Kitty" -6ren">
gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 14:05:16 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com