博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
configparser.ConfigParser.writer()
阅读量:6847 次
发布时间:2019-06-26

本文共 1342 字,大约阅读时间需要 4 分钟。

①    write(fileobject, space_around_delimiters=True)

Write a representation of the configuration to the specified file object,which must be opened in text mode(accepting strings),This representation can ba parsed by a future read() call.if space_around_delimiters is true,delimiters between keys an values are surrounded by spaces.

config = configparser.Configparser()

must be opened in text mode (accept strings):只能使用text模式打开的文件才能被写入,with open('users.pkl', 'w') as f:
config.writer(f)

②read(filenames, encoding=None)            If filenames is a string or path-like object, it is treated as a single filename. If a file named in filenames cannot be opened, that file will be ignored. This is designed so that you can specify a list of potential configuration file locations (for example, the current directory, the user’s home directory, and some system-wide directory), and all existing configuration files in the list will be read.

If none of the named files exist, the ConfigParser instance will contain an empty dataset. An application which requires initial values to be loaded from a file should load the required file or files using read_file() before calling read() for any optional files:

import configparser, os

config = configparser.ConfigParser()

config.read_file(open('defaults.cfg'))

转载于:https://blog.51cto.com/13118411/2167133

你可能感兴趣的文章
Paxos算法详细图解
查看>>
如何用Exchange Server 2003 构建多域名邮件系统
查看>>
httpd服务如何开机启动
查看>>
JAVA帮助文档全系列 JDK1.5 JDK1.6 JDK1.7 官方中英完整版下载
查看>>
android 1.6中LinearLayout getBaseline函数的一个bug
查看>>
shell3
查看>>
分享几个好用的工具,有效提升工作效率
查看>>
论北京北漂的家人们
查看>>
delphi 检查用户输入必须是汉字串
查看>>
思科交换机和路由器设备实现DHCP功能
查看>>
MongoDB安装与操作大全
查看>>
人我的是好有是的好sula
查看>>
编译工程时报java:[1,0] illegal character: \65279问题排查与解决过
查看>>
RHEL6子接口及双网卡绑定配置
查看>>
常见系统故障排查
查看>>
正则验证手机号是否合法
查看>>
《Git权威指南》读书笔记 第四章 git初始化
查看>>
《Head first HTML与CSS 第二版》读书笔记 第九章 盒模型
查看>>
《Python面向对象……》之目录
查看>>
集群入门简析及LB下LVS详解
查看>>