美文网首页
python 从配置文件获取URL

python 从配置文件获取URL

作者: Demon_半夏 | 来源:发表于2018-09-27 10:25 被阅读0次

1.添加一个config.ini文件:

[test]

url = http://192.168.8.231:8000

2.编写用例时获取url:

import getcwd

import os

import configparser

 # 从配置文件获取URL

    path = getcwd.get_cwd()

    config_path = os.path.join(path, 'config.ini')

    config = configparser.ConfigParser()

    config.read(config_path, encoding="utf-8-sig")

    config_url = config.get('test', 'url')

    # 访问接口

    url = config_url + '/index/login'  # 本地

相关文章

网友评论

      本文标题:python 从配置文件获取URL

      本文链接:https://www.haomeiwen.com/subject/qeasoftx.html