1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > python接口自动化(四十四)- 公共模块configparser读取ini数据库 邮箱配置文件(单独说明)

python接口自动化(四十四)- 公共模块configparser读取ini数据库 邮箱配置文件(单独说明)

时间:2018-07-07 14:10:22

相关推荐

python接口自动化(四十四)- 公共模块configparser读取ini数据库 邮箱配置文件(单独说明)

1、配置文件示例 : cfg.ini

#coding=utf-8import osimport configparserimport pymysqlpymysql.install_as_MySQLdb()cur_path = os.path.dirname(os.path.realpath(__file__))configPath = os.path.join(cur_path, "cfg.ini")conf = configparser.ConfigParser()conf.read(configPath, encoding='utf-8')#emailsmtp_server = conf.get("email", "smtp_server")sender = conf.get("email", "sender")psw = conf.get("email", "psw")receiver = conf.get("email", "receiver")cc_receiver = conf.get("email", "cc_receiver")port = conf.get("email", "port")#mysql:host = conf.get("mysql", "host")user = conf.get("mysql", "user")passwd = conf.get("mysql", "passwd")mysql_port = conf.get("mysql", "port")charset = conf.get("mysql", "charset")middle_db = conf.get("mysql", "middle_db")core_db = conf.get("mysql", "core_db")admin_db = conf.get("mysql", "admin_db")auth_db = conf.get("mysql", "auth_db")

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。