P

python 常用模板

root 2024-07-26

经常写python。索性写了个模板。把常用的库写写

import time
import logging

# 配置logging模块
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def main():
    # 记录开始时间
    start_time = time.time()

    # 你的主要代码逻辑
    logging.info("This is the main function")

    # 模拟一些延迟
    time.sleep(2)

    # 记录结束时间
    end_time = time.time()

    # 计算并打印执行时间
    elapsed_time = end_time - start_time
    logging.info(f"Script executed in {elapsed_time:.2f} seconds")

if __name__ == "__main__":
    main()

PREV
虚拟卡出金——pokepay

评论(0)

发布评论