1.配置
#config.ini的内容如下 [numbers] pi:3.141592653 e:2.718281828 [messages] head:This is head text! result:This is result text! #配置模块configparser import configparser File="config.ini" config=configparser.ConfigParser() #读取配置文件 config.read(File) print(config["numbers"].get("pi")) print(dict(config["numbers"]))
2.日志
import logging logging.basicConfig(level=logging.INFO,filename="mylog.log") logging.info("Start") logging.info("Try to divide 1 by 0") print(1/0) logging.info("OK")