You've already forked www.colben.cn
update
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user