博客
关于我
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工作笔记006---Mysql服务器磁盘爆满了_java.sql.SQLException: Error writing file ‘tmp/MYfXO41p‘
查看>>
MySQL工具1:mysqladmin
查看>>
mysql常用命令
查看>>
MySQL常用命令
查看>>
mysql常用命令
查看>>
Warning: mkdir(): No such file or directory in D:\phpstudy_pro\WWW\**** linux mkdir
查看>>
MySQL常用指令集
查看>>
mysql常用操作
查看>>
MySQL常用日期格式转换函数、字符串函数、聚合函数详
查看>>
MySQL常见函数
查看>>
MySQL常见架构的应用
查看>>
MySQL常见的三种存储引擎(InnoDB、MyISAM、MEMORY)
查看>>
MySQL常见的三种存储引擎(InnoDB、MyISAM、MEMORY)
查看>>
MySQL常见约束条件
查看>>
MySQL常见错误
查看>>
MySQL常见错误分析与解决方法总结
查看>>
mysql并发死锁案例
查看>>
MySQL幻读:大家好,我是幻读,我今天又被解决了
查看>>
MySQL底层概述—1.InnoDB内存结构
查看>>
MySQL底层概述—2.InnoDB磁盘结构
查看>>