标签:__file__ cti 读取配置 pat ret col get value 读取
config.ini
[phone] imei = 123456789 num = 0 / 14 build = 00WWYL
test.py
CUR_DIR = os.path.dirname(os.path.abspath(__file__)) configFilePath = os.path.join(CUR_DIR, ‘../bin/config.ini‘) def get_config_values(self, section, option): config = configparser.ConfigParser() # 避免乱码问题读取配置文件 config.read(configFilePath, encoding=‘utf-8‘) return config.get(section=section, option=option) IMEI = get_config_values(‘phone‘, ‘imei‘) num = get_config_values(‘phone‘, ‘num‘) build = get_config_values(‘phone‘, ‘build‘)
标签:__file__ cti 读取配置 pat ret col get value 读取
原文地址:https://www.cnblogs.com/blackpink/p/14769313.html