首页 > 其他 > 详细

configparser----配置文件模块

时间:2020-01-07 21:59:55      阅读:100      评论:0      收藏:0      [点我收藏+]

配置文件配置方法:

[ElementProfile]
landing=id:btn_account
error_message=xpath://div[@class=pop_head]/div/span
username_error=xpath://div[@class=username_msg msg]/span
username=id:username
error_content=xpath://div[@class=protocol]/a[@ href="//about.58.com/home2/home_pc/syxyjgg/771.html"]

 

configparser模块

1、第三方模块安装:pip install configparser

2、导入模块:import configparser

3、模块的使用:

 1 import configparser
 2 
 3 class ReaDconfigurationFile(object):
 4     def __init__(self,file_name=None , node=None):
 5         if file_name == None:
 6             file_name = rF:\项目\京东登陆\Testcfg\Configuration_file.ini
 7         if node == None:
 8             self.node = ElementProfile
 9         self.file = self.read_file(file_name)
10 
11     #加载配置文件
12     def read_file(self,file_name):
13         file = configparser.ConfigParser()
14         file.read(file_name)
15         return file
16 
17     #读取配置文件的value值
18     def obtain_ini_value(self,key):
19         file_value=self.file.get(self.node,key)
20         return file_value

configparser----配置文件模块

原文:https://www.cnblogs.com/zihkj/p/12163762.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!