获取配置文件信息——configparser
配置文件host.int格式如下:
[host]
product=xxxxxxxxxx
test=xxxxxxxxxx
python 3.x代码如下:
import os,configparser
def filePath(path):
return os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))),path)
def getHostData():
#获取配置文件host信息
cf=configparser.ConfigParser()
cf.read(filePath('config\\host.ini'))
product=cf.get('host','product')
test=cf.get('host','test')
return product,test
获取配置文件信息——configparser的更多相关文章
- SpringBoot项目中,获取配置文件信息
1.在配置文件中设置信息,格式如下 wechat: mpAppId: wxdf2b09f280e6e6e2 mpAppSecret: f924b2e9f140ac98f9cb5317a8951c71 ...
- SpringBoot配置分析、获取到SpringBoot配置文件信息以及几种获取配置文件信息的方式
Spring入门篇:https://www.cnblogs.com/biehongli/p/10170241.html SpringBoot的默认的配置文件application.properties ...
- 使用Spring注解获取配置文件信息
需要加载的配置文件内容(resource.properties): #FTP相关配置 #FTP的IP地址 FTP_ADDRESS=192.168.1.121 FTP_PORT=21 FTP_USERN ...
- .Net FrameWork获取配置文件信息
今天在做项目的时候需要到配置文件中读取信息,之前自己并没有操作过,今天算是完成自己的一个心愿.读取配置文件中的信息并不难,大致思路是: 1.载入配置文件,获取配置文件的实例. 2.获取配置文件的节点 ...
- mybatis整合spring获取配置文件信息出错
描述:mybatis整合spring加载jdbc.properties文件,然后使用里面配置的值来 配置数据源,后来发现用户变成了admin- jdbc.properties的配置: 加载配置: 报错 ...
- java获取配置文件信息
两个类 package com.censoft.util; import java.util.Properties; import java.io.*; import java.util.ArrayL ...
- .Net Standard(.Net Core)实现获取配置信息
一.前言 在.Net Framework框架有专门获取webconfig配置的方法供我们使用,但是在.Net Core或者.Net Standard中没有可以直接使用的方法来获取配置文件信息,下面就来 ...
- spring cloud --- config 配置中心 [本地、git获取配置文件]
spring boot 1.5.9.RELEASE spring cloud Dalston.SR1 1.前言 spring cloud config 配置中心是什么? 为了统一管理配 ...
- python-通过configparser模块读取后缀为 .ini 的配置文件信息
前言 一般为了方便会将路径,连接信息等写到配置文件(通常会将这些信息写到yaml,ini....配置文件)中,configparser模块读取后缀为 .ini 的配置文件信息 配置文件格式 #存在 c ...
随机推荐
- PAT005 Path in a Heap
题目: Insert a sequence of given numbers into an initially empty min-heap H. Then for any given index ...
- js用计时器加载大量dom
改进前: <table><tbody></tbody></table> var tbody=document.getElementsByTagName( ...
- Unity3D必备知识: 物理学公式
一.质点的运动(1)——直线运动 1)匀变速直线运动 1.平均速度V=s/t(定义式) 2.有用推论Vt*Vt-Vo*Vo=2as 3.中间时刻速度Vt/2=V平=(Vt+Vo)/2 4.末速度Vt= ...
- VC++ Debug格式化数值显示
When you watch variables in the Watch or Quick Watch window, the values are displayed using the defa ...
- Linux shell(. /path/filename)
在 /etc/profile 文件中,有一段脚本: if [ -f /etc/bash.bashrc ]; then . /etc/bash.bashrc fi 这里的 “点号 + 空格 + 文件” ...
- 第一次使用Xamarin就上手 - 安裝Xamarin
http://xamarintech.blogspot.tw/2013/06/xamarin-xamarin-step-by-step-part1.html http://xamarintech.bl ...
- 亲测Google开源JPEG图片压缩算法,可将JPEG文件缩小%35
具体方法如下(windows 平台) GitHub上下载guetzli源码,地址https://github.com/google/guetzli GitHub上下载 vcpkg源码,地址https: ...
- 【bzoj4872】[Shoi2017]分手是祝愿 数论+期望dp
题目描述 Zeit und Raum trennen dich und mich. 时空将你我分开. B 君在玩一个游戏,这个游戏由 n 个灯和 n 个开关组成,给定这 n 个灯的初始状态,下标为从 ...
- 锚点链接 阻止a标签跳转
参考 http://blog.csdn.net/awe5566/article/details/22583699 href="#downJacket" 锚点链接 必须写: 但又 ...
- 带jsk证书,请求https接口
首先是三个返回的实体类 BaseVo.java package https2; import java.io.Serializable; import java.lang.reflect.Invoca ...