#ini文件
[web_config] #前台ldap登陆: login_name=ut251 login_pwd=wanghu123
读取ini文件内容
def read_config(section, key): try: config = configparser.ConfigParser() # 类实例化 # ini文件路径 config_path = os.path.join(product_path, "config.ini") config.read(config_path) vilue = config.get(section, key) return vilue except Exception as e: return ('config文件获取失败:%s' % e) if __name__ == '__main__': a = read_config("web_config", "login_name") print(a)
标签:__,文件,读取,python,read,ini,path,config From: https://www.cnblogs.com/luckywh/p/15908000.html