zoukankan      html  css  js  c++  java
  • python3+requests接口自动化-配置文件

    1.cfg.ini打开,这里写配置文件内容

    [email]
    smtp_server = smtp.qq.com
    port = 456
    sender = jayson@e-veb.com

    ;psw是邮箱的授权码
    psw = xxx


    receiver = jayson@e-veb.com

    2.用readConfig.py读取配置文件
     1 import os
     2 import ConfigParser
     3 
     4 cur_path = os.path.dirname(os.path.realpath(__file__))
     5 configPath = os.path.join(cur_path,"cfg.ini")
     6 conf = ConfigParser.ConfigParser()
     7 conf.read(configPath)
     8 
     9 smtp_server = conf.get("email","smtp_server")
    10 
    11 sender = conf.get("email","sender")
    12 
    13 psw = conf.get("email","psw")
    14 
    15 receiver = conf.get("email","receiver")
    16 
    17 port = conf.get("email","port")

    3.读取的内容就是传入第二步操作里面需要调用邮箱的配置信息

  • 相关阅读:
    Apache 基础
    Oracle
    DevOps
    Ansible
    Iptables 和Firewall 防火墙
    防火墙
    Linux
    Intellij IDEA 快捷键大全
    Java8,9 新特性
    Jmeter
  • 原文地址:https://www.cnblogs.com/jayson-0425/p/9809681.html
Copyright © 2011-2022 走看看