python 读取配置文件
来源:互联网 发布:ug五轴联动编程 编辑:程序博客网 时间:2024/06/05 07:38
Python读取配置文件并打印文件信息
配置文件field_len.conf内容为:
[ddl_max_len]
NUMBER_MAX_LEN=10
VARCHAR2_MAX_LEN=1024
[dml_max_len]
NUMBER_MAX_LEN=10
VARCHAR2_MAX_LEN=1024
BLOB_MAX_LEN=500M
FLOAT_MAX_LEN = P20S8
DATE = 12
TIMESTAMP(6) = 12
import ConfigParserdef db_get_args_cfginfo(db_field_len_file): db_config = ConfigParser.ConfigParser() db_config.read(db_field_len_file) return db_configdb_field_len_file = "C:/i2test/field_len.conf"db_config = db_get_args_cfginfo(db_field_len_file)dcs = db_config.sections()print dcsfor config_data_type in db_config.options(dcs[0]): print "-----------------------------" print config_data_type print config_data_type.upper()for config_data_type in db_config.options(dcs[1]): print "==============================" print config_data_type print config_data_type.upper()
执行程序结果:
['ddl_max_len', 'dml_max_len']
-----------------------------
number_max_len
NUMBER_MAX_LEN
-----------------------------
varchar2_max_len
VARCHAR2_MAX_LEN
==============================
number_max_len
NUMBER_MAX_LEN
==============================
varchar2_max_len
VARCHAR2_MAX_LEN
==============================
blob_max_len
BLOB_MAX_LEN
==============================
float_max_len
FLOAT_MAX_LEN
==============================
date
DATE
==============================
timestamp(6)
TIMESTAMP(6)
0 0
- Python读取ini配置文件
- Python读取配置文件
- python读取配置文件
- 用Python读取配置文件
- Python读取ini配置文件
- python读取配置文件
- python 读取配置文件
- python读取properties配置文件
- Python读取配置文件
- 【Python】配置文件读取
- Python读取配置文件
- python 读取配置文件
- Python读取INI配置文件
- Python 读取配置文件
- python读取配置文件
- python 读取配置文件
- python读取配置文件configparser
- python读取配置文件
- 【oracle游标一】参数游标
- 748 B. Santa Claus and Keyboard Check
- 使用ContentResolver访问通讯录ContentProvider
- AJAX基础
- CSS之display属性
- python 读取配置文件
- spring-security 在jsp中的标签库
- 对象作用域与Servlet事件监听器
- linux文件系统简介
- 存储管理——虚拟内存
- 748 C. Santa Claus and Robot codeforces
- C程序设计 例题5.11 译密码
- 利用Linux信号SIGUSR1调试嵌入式程序
- Linux命令行操作