#coding:utf-8

import os
import configparser#导入配置文件包

def read_conf(option,section):
    cur_path = os.path.dirname(os.path.realpath(__file__))  # 获取当前目录
    configPath = os.path.join(cur_path, "config.ini")  # 拼接目录跟文件名
    conf = configparser.ConfigParser()  # 新建实例
    conf.read(configPath)  # 读取config.ini文件
    peizhi=conf.get(option,section)#获取配置
    return peizhi

下面这个就是我config.ini文件的配置

[web]
user = zhangsan
pwd  = 111111

[email]
smtp_server = smtp.qq.com
port = 465
sender = 504527497@qq.com

 

相关文章:

  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2022-01-14
  • 2021-07-17
猜你喜欢
  • 2021-05-27
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
相关资源
相似解决方案