/* 时间:2021/12/29 功能:计算执行时间 logging 目录: 一: 计算执行时间 logging 二: logging */
一: 计算执行时间 logging
# 测试时间 import time mysql_url = "192.168.52.128" def decorator(func): def inner(): begin = time.time() func() end = time.time() result = end - begin print("执行时间: ", result) return inner
二: logging
import logging logging.basicConfig(level=logging.DEBUG, format="%(asctime)s: %(filename)s_[lineno:%(lineno)d] %(levelname)s %(message)s: ", filename="log.txt", filemode="w")