首页 > 其他 > 详细

十五.配置和日志

时间:2019-04-10 23:02:03      阅读:107      评论:0      收藏:0      [点我收藏+]

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")

 

十五.配置和日志

原文:https://www.cnblogs.com/i201102053/p/10686622.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!