Python: How would you save a simple settings/config file?

后端 未结 6 787
迷失自我
迷失自我 2020-12-04 04:52

I don\'t care if it\'s JSON, pickle, YAML, or whatever.

All other implementations I have seen are not forwards compatible, so

6条回答
  •  情书的邮戳
    2020-12-04 05:27

    Try using ReadSettings:

    from readsettings import ReadSettings
    data = ReadSettings("settings.json") # Load or create any json, yml, yaml or toml file
    data["name"] = "value" # Set "name" to "value"
    data["name"] # Returns: "value"
    

提交回复
热议问题