Github:https://github.com/lotapp/PySnooperhtml
pip install pysnooper
python
使用:分析整個代碼git
@pysnooper.snoop()
def avg(args):
return sum(args) / len(args)
PS:調試代碼片斷github
with pysnooper.snoop():
code
import functools
import pysnooper
# 分析整個代碼
@pysnooper.snoop()
def sum(args):
return functools.reduce(lambda x, y: x + y, args)
def avg(args):
# return sum(args) / len(args)
sum_num = sum(args)
# 分析片斷代碼
with pysnooper.snoop():
avg_num = sum_num / len(args)
return avg_num
# 求和
sum(list(range(1, 101)))
# 平均值
avg(list(range(1, 101)))