首页 > 编程语言 > 详细

python configparse

时间:2018-09-28 18:27:57      阅读:180      评论:0      收藏:0      [点我收藏+]
# 参考:https://www.cnblogs.com/lily1989/p/8401005.html
#  https://blog.csdn.net/willhuo/article/details/49512557
import configparser
config = configparser.ConfigParser()
config.read(‘cost.ini‘)
# 读取
print(config.get(‘tests‘, ‘ip‘))
# 或者print(config[‘tests‘][‘ip‘])
# 写入
try:
    config.add_section("School")
    config.set("School","IP","10.15.40.123")
except configparser.DuplicateSectionError:
    print("Section ‘Match‘ already exists")


with open(‘cost.ini‘,‘w‘) as fp:
    config.write(fp)

python configparse

原文:https://www.cnblogs.com/lajiao/p/9719947.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!