zoukankan      html  css  js  c++  java
  • 7-7接口自动化测试框架设计开发之模型搭建--运用配置文件处理请求数据

     本章只用到了server.ini和handle_init.py,实现到效果是,获取server.ini中的值

    server.ini
    [server]
    host=http://www.imooc.com
    username=哈哈
    password=1111
    is_run=3
    handle_init.py
    #
    coding=utf-8 import sys import os import openpyxl import configparser base_path = "/Users/jiangjuanjuan/Downloads/itemA/Config/server.ini" class HandleInit: def load_init(self): cf = configparser.ConfigParser() cf.read(base_path,encoding='utf-8-sig') return cf def get_value(self,key,section=None): ''' 获取ini里面的value ''' if section == None: section = 'server' try: cf = self.load_init() data = cf.get(section, key) except Exception: print("没有获取到值") data = None return data if __name__ == '__main__': hi = HandleInit() print(hi.get_value("username"))

      

     

  • 相关阅读:
    vue零散知识
    vue router 和 组件生命周期的理解
    未搞懂的问题
    前端问题总结
    垂直居中
    css,js加载阻塞页面渲染的理解
    node 学习
    自定义事件
    学习react 遇到的问题
    [AHOI2001]彩票摇奖
  • 原文地址:https://www.cnblogs.com/JuanZi-Sunny/p/13489865.html
Copyright © 2011-2022 走看看