如何解决我将如何存储值?
所以我一直在尝试存储一个值,但是我意识到我只在打印它,我使用的是configupdater模块,我想知道如何在此处存储特定值:
updater.read('settings.ini')
g = updater['Trading Settings']['minimum_value_gain'].value
updater.update_file()
print(g)
Output:
5
值是5,但是随着我创建的一些代码的改变,它每5分钟更改一次,但是我想存储我拥有的值,例如,可以说它是5。 我的config.ini:
[Trading Settings]
#Shows the percentage of value you will be gaining from each trade (0.01 = 1%). Set to "none" to disable the limit.
minimum_value_gain = 5
解决方法
我看到您在project readme之后取得了一些成功,我认为这实际上是实现逻辑错误。
让我们看看你应该做什么
- 读取文件
- 更新值
- 写入新文件
现在您正在读取文件,并且有一个变量g
用于引用updater['Trading Settings']['minimum_value_gain'].value
。
您实际上错过了第2步,因为您在这里从未修改任何内容,这是您应如何执行此操作的示例
# file unmodified,changes only the value associated with the
# updater object
updater['Trading Settings']['minimum_value_gain'].value = 6
# now we will update the file with the changed value
updater.update_file() # or updater.write('path/to/some/new/file')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。