This commit is contained in:
2021-11-14 15:52:46 +08:00
parent 915c231124
commit 1e344dc204
112 changed files with 1039 additions and 1039 deletions

View File

@@ -6,7 +6,7 @@ tags: ["python", "configparser"]
categories: ["python"]
---
# 样例文件
## 样例文件
- 该类配置文件可以包含一个或多个节section每个节可以有多个参数键=值)。
- 样例配置文件(/proj/conf/example_conf
```
@@ -22,7 +22,7 @@ categories: ["python"]
```
- 上面配置文件中用的是冒号,也可以用等号。
# 读取配置文件
## 读取配置文件
- 示例文件: example.py
```python
# -*- coding: utf-8 -*-
@@ -56,7 +56,7 @@ categories: ["python"]
blog = csdn.n
```
# 写入配置文件
## 写入配置文件
- 示例
```python
import ConfigParser
@@ -78,7 +78,7 @@ categories: ["python"]
size = 1024
```
# ConfigParser方法
## ConfigParser方法
- 创建ConfigParser实例
```python
config=ConfigParser.ConfigParser()
@@ -118,9 +118,9 @@ categories: ["python"]
config.write(obj_file)
```
# 综合实例
## 综合实例
```python
#coding=utf-8
##coding=utf-8
import ConfigParser