python通过configparser 读取配置文件

配置文件config.properties:

[UrlSection]

url.webdriver=http://localhost:8080

url.appserver=http://localhost

[PlatfromSection]

platform.os=windows

platform.browser=chrome

[PublishSection]

 Test1.type=type1

Test1.name=testname

[CommandSection]

android.command=adb start-server

flake=python -m pip install flake8

 

读取文件

import configparser

import os

import time

from selenium import webdriver

from selenium.webdriver.common.by import By

from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.support.ui import WebDriverWait

 

config = configparser.RawConfigParser() config.read(os.path.abspath('config.properties'))

platform_os = config.get('PlatfromSection', 'platform.os')

browser_name = config.get('PlatfromSection', 'platform.browser')

webdriver_url = config.get('UrlSection', 'url.webdriver')

app_url = config.get('UrlSection', 'url.appserver’)

browser_info = platform_os + "_" + browser_name print(browser_info)

posted @ 2017-06-15 13:44  金竹多多  Views(320)  Comments(0Edit  收藏  举报