Python例子
- Python例子-图片验证码
- Python例子-将一个list的值加入字典,然后再插入到一个空列表
- Python例子-爬取糗事百科首页内容
- Python例子-urllib模拟游览器
- Python例子-读取远程页面并写入本地页面
- Python例子-通过装饰器实现已有函数执行时间的统计
- Python例子-使用闭包函数输出不同人的对话
- Python例子-面向对象(烤地瓜)
- Python例子-复制文件
- Python例子-计算阶乘 n! = 1 * 2 * 3 * ... * n
- Python例子-8个老师分配到3个办公室
- Python例子-求1~100中平方根是整数的数
- Python例子-求100-999之间所有的"水仙花数"
- Python例子-1、2、3、4组成互不相同不重复的三位数
- Python例子-年份是否是闰年
- Python例子-设计“过7游戏”
- Python例子-九九乘法表
- Python例子-统计字符串中,各个字符的个数
- Python例子-测试身材是否标准
- Python例子-计算1~100的累加和
- Python例子-猜拳游戏
- Python例子上公交车有座位可以坐下
Python例子-通过装饰器实现已有函数执行时间的统计
装饰器实现已有函数执行时间的统计
import time def get_time(func): start_time = time.time() func() end_time = time.time() run_time = end_time - start_time print('函数的执行时间是%s'%run_time) return get_time @get_time def test(): i = 0 for i in range(10000): print(i) i += 1 ''' 执行结果 0 1 2 3 ... 9996 9997 9998 9999 函数的执行时间是0.07971668243408203 '''
最后修改:2020年3月7日 23:06