python 3 ini配置文件操作
2015-12-01 18:45
507 查看
import configparser #configparser模块和配置文件 def ini_create(): config=configparser.ConfigParser() config['SystemInfo']={'port':'80'} config['GameInfo']={'level':1,'scores':0} with open(r'/home/rain/test/example.ini','w') as configfile: config.write(configfile) def ini_read_write(): config=configparser.ConfigParser() config.read(r'/home/rain/test/example.ini') print (config) config['SystemInfo']['port']='8080' config.set('GameInfo','scores','1000') for item in config.items('GameInfo'): print(item) with open(r'/home/rain/test/example.ini','w') as configfile: config.write(configfile) if __name__ == '__main__': ini_create() ini_read_write()
相关文章推荐
- Python WindowsError
- Python之服务器模块设计学习
- k-近邻算法(KNN)--1简单原理介绍与实践---by香蕉麦乐迪
- ubuntu 下配置Python wxWidgets (复制自官方网站)
- Python--操作文件和目录
- Python的安装
- Python基础教程(十三):JSON、练习题100题
- Python基础教程(十二):GUI编程、版本区别、IDE
- Python基础教程(十一):多线程、XML解析
- python webdriver中对不同下拉框通过文本值的选择
- Python基础教程(九):面向对象、正则表达式
- Python基础教程(八):日期和时间、文件I/O、异常处理
- leetcode之Reverse Linked List
- Python基础教程(七):函数、模块
- python -模拟购物 -赊账版 粗糙之极
- python 设置网页全屏显示
- Python基础教程(六):list、tuple、dictionary
- Python基础教程(五):数字、字符串
- Python基础教程(四):循环语句
- python pymouse 控制鼠标