博客
关于我
Python读取ini配置文件
阅读量:136 次
发布时间:2019-02-27

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

config.ini配置文件内容为:

[config]url=http://***.com

 读取config.ini配置文件的Python代码为:

import configparserclass ReadConfig:    def __init__(self):        self.cf = configparser.ConfigParser()        self.cf.read('../../../resource/config.ini', encoding='utf-8')    def getvalue(self, param):        value = self.cf.get("config", param)        return valueprint(ReadConfig().getvalue('url'))

 

转载地址:http://afnb.baihongyu.com/

你可能感兴趣的文章
mysql的 if else , case when then, IFNULL
查看>>
MySQL的10种常用数据类型
查看>>
MySQL的btree索引和hash索引的区别
查看>>
mysql的cast函数
查看>>
MySql的CRUD(增、删、改、查)操作
查看>>
MySQL的DATE_FORMAT()函数将Date转为字符串
查看>>
mysql的decimal与Java的BigDecimal用法
查看>>
MySql的Delete、Truncate、Drop分析
查看>>
MySQL的Geometry数据处理之WKB方案
查看>>
MySQL的Geometry数据处理之WKT方案
查看>>
mysql的grant用法
查看>>
Mysql的InnoDB引擎的表锁与行锁
查看>>
mysql的InnoDB引擎索引为什么使用B+Tree
查看>>
MySQL的InnoDB默认隔离级别为 Repeatable read(可重复读)为啥能解决幻读问题?
查看>>
MySQL的insert-on-duplicate语句详解
查看>>
mysql的logrotate脚本
查看>>
MySQL的my.cnf文件(解决5.7.18下没有my-default.cnf)
查看>>
MySQL的on duplicate key update 的使用
查看>>
MySQL的Replace用法详解
查看>>
mysql的root用户无法建库的问题
查看>>