Python3.x:logging模块对运行过程记录
示例:
import logging # 设置 logger = logging.getLogger() #set loghandler,文件在py所在的目录下 file = logging.FileHandler("yzzq_jys.log") logger.addHandler(file) #set formater formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s") file.setFormatter(formatter) #set log level logger.setLevel(logging.NOTSET) #调用 if __name__ == ‘__main__‘: logger.info("传递参数错误,参数依次(参数之间用空格隔开)")