随笔分类 - 自定义函数
摘要:# grep -rl 'python' /root 搜索root目录下文件内容包含python的文件名路径 import os def init(func): def wrapper(*args,**kwargs): res = func(*args,**kwargs) next(res) return res return w...
阅读全文
摘要:参考博客:http://www.cnblogs.com/linhaifeng/articles/6384466.html
阅读全文
摘要:模块的搜索顺序 #内存----》内置------》sys.path import sys print(sys.path) #打印出当前的sys.path的搜索路径,在内存和内置中都找不到该模块的情况下会到下面的这些路径逐个去找,并以打印出的顺序作为优先级。 #['D:\\Python_OldBoy\\day05\\模块与包', 'D:\\Python_OldBoy', 'C:\\Users...
阅读全文
摘要:同级目录导入模块直接导入,一个py文件就是一个模块 #导入模块的方法: 1、import 模块名1,模块名2 #注意只是模块名,不药写。py等后缀 2、import 模块名 as 别名 3、from 模块名 import 函数名 4、from 模块名 import * 跟__all__ = ['money','read1']结合使用 '''1、import直接导入模块名 impor...
阅读全文
摘要:import time def timmer(func): def wrapper(*args,**kwargs): print("----->from timmer_wrapper") start_time = time.time() reg = func(*args,**kwargs) stop_time = ti...
阅读全文
摘要:import time def timmer(func): #这里是要把需要装饰的函数名传递进来,方便后面调用。如果不传函数名而是直接调用,在调用的位置会报:RecursionError: maximum recursion depth exceeded while calling a Python object def wrapper(*args,**kwargs): ...
阅读全文
摘要:# tail -f a.txt |grep 'python' #tail -f a.txt import time def tail(conf): with open(conf,encoding='utf-8') as f: f.seek(0,2) while True: f1 = f.readline().strip() ...
阅读全文

浙公网安备 33010602011771号