如何使用Python3读写INI文件?

如何使用Python3读写INI文件?,第1张

如何使用Python3读写INI文件

可以从以下开始:

import configparserconfig = configparser.ConfigParser()config.read('FILE.INI')print(config['DEFAULT']['path'])     # -> "/path/name/"config['DEFAULT']['path'] = '/var/shared/'    # updateconfig['DEFAULT']['default_message'] = 'Hey! help me!!'   # createwith open('FILE.INI', 'w') as configfile:    # save    config.write(configfile)

您可以在官方configparser文档中找到更多信息。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zaji/5618105.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存