python - 一般: always saving settings on close vs saving only when changed

标签 python coding-style

我正在对一个小型 python 应用程序进行 beta 测试 - 每当应用程序关闭时,即使我没有进行任何更改,设置也会被保存。我想知道这是否是一般做法 - 听起来设置只应在进行更改时保存,但是否有原因(除了降低复杂性之外)专业保存设置始终处于关闭状态?

最佳答案

如果您的应用使用 configparse例如,如果在关闭过程中有类似以下内容,您将重写文件:

with open('example.ini', 'w') as configfile:
  config.write(configfile)

如果你不做任何改变的话,它和以前没有什么不同。

关于python - 一般: always saving settings on close vs saving only when changed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9001434/

相关文章:

haskell - 在没有多余代码的情况下在 Haskell 中展开数据类型

PHP 新手 : How to write good code

coding-style - 是否有任何语言具有 while-else 流结构?

python - Dataframe 中的 Loop、iloc 和 loc?

Python:求和的 Lambda

python - 多处理并行距离计算方法

Python 导入编码风格

python - 回调函数中的 ctypes POINTER(c_void_p)

python - 使用 python 计算 excel 中的重复行,我收到错误 TypeError : a bytes-like object is required, not 'str'

SQL - 选择 null 作为 FIELDNAME?