2020年7月5日

logging模块

摘要: #logging.basicConfig 简单配置 import logging #同时输出文件和控制台 fh = logging.FileHandler('tmp.log',encoding='utf-8') sh = logging.StreamHandler() logging.basicCo 阅读全文

posted @ 2020-07-05 21:42 Ajin0427 阅读(120) 评论(0) 推荐(0)

2020年6月15日

装饰器for(python)

摘要: Python 简单的装饰器 import time def wrapper(f): def inner(*args,**kwargs): start_time = time.time() #例如 ''' 添加额外功能:执行装饰器之前的操作 ''' ret =f(*args,**kwargs) ''' 阅读全文

posted @ 2020-06-15 23:54 Ajin0427 阅读(91) 评论(0) 推荐(0)

2020年6月6日

Python替换文件内容函数

摘要: Python替换文本的简易函数 一行一行替换 import os def fun(path,old_content,new_content): with open(path,encoding='utf-8') as f1,\ open('test',encoding='utf-8',mode='w' 阅读全文

posted @ 2020-06-06 19:04 Ajin0427 阅读(166) 评论(0) 推荐(0)

导航