首页 > 其他分享 >pysnooper打印运行过程值

pysnooper打印运行过程值

时间:2023-06-18 10:23:40浏览次数:32  
标签:10 13 打印 pysnooper 36.685643 lst var line 运行

# with

import random


import pysnooper


def print_upper_mid_lower(): lst = [] for i in range(10): lst.append(random.randrange(1, 1000)) with pysnooper.snoop(): lower = min(lst) upper = max(lst) mid = (lower + upper) / 2 print(lower, mid, upper) if __name__ == '__main__': print_upper_mid_lower() # 结果 D:\miniconda3\python.exe D://调试库pysnooper.py 252 598.0 944 Source path:... D://pysnooper.py New var:....... lst = [295, 352, 493, 662, 887, 423, 385, 944, 252, 903] New var:....... i = 9 10:09:42.334110 line 24 lower = min(lst) New var:....... lower = 252 10:09:42.335114 line 25 upper = max(lst) New var:....... upper = 944 10:09:42.335114 line 26 mid = (lower + upper) / 2 New var:....... mid = 598.0 10:09:42.335114 line 27 print(lower, mid, upper) Elapsed time: 00:00:00.001004 Process finished with exit code 0
# 装饰器
import random

import pysnooper


@pysnooper.snoop()
def print_upper_mid_lower():
    lst = []
    for i in range(10):
        lst.append(random.randrange(1, 1000))

    lower = min(lst)
    upper = max(lst)
    mid = (lower + upper) / 2
    print(lower, mid, upper)

if __name__ == '__main__':
    print_upper_mid_lower()

# 结果
D:\miniconda3\python.exe D://调试库pysnooper.py
81 484.5 888
Source path:... D://pysnooper.py
10:13:36.684644 call         7 def print_upper_mid_lower():
10:13:36.685643 line         8     lst = []
New var:....... lst = []
10:13:36.685643 line         9     for i in range(10):
New var:....... i = 0
10:13:36.685643 line        10         lst.append(random.randrange(1, 1000))
Modified var:.. lst = [94]
10:13:36.685643 line         9     for i in range(10):
Modified var:.. i = 1
10:13:36.685643 line        10         lst.append(random.randrange(1, 1000))
Modified var:.. lst = [94, 204]
10:13:36.685643 line         9     for i in range(10):
Modified var:.. i = 2
10:13:36.685643 line        10         lst.append(random.randrange(1, 1000))
Modified var:.. lst = [94, 204, 81]
10:13:36.685643 line         9     for i in range(10):
Modified var:.. i = 3
10:13:36.685643 line        10         lst.append(random.randrange(1, 1000))
Modified var:.. lst = [94, 204, 81, 512]
10:13:36.685643 line         9     for i in range(10):
Modified var:.. i = 4
10:13:36.685643 line        10         lst.append(random.randrange(1, 1000))
Modified var:.. lst = [94, 204, 81, 512, 830]
10:13:36.685643 line         9     for i in range(10):
Modified var:.. i = 5
10:13:36.685643 line        10         lst.append(random.randrange(1, 1000))
Modified var:.. lst = [94, 204, 81, 512, 830, 677]
10:13:36.685643 line         9     for i in range(10):
Modified var:.. i = 6
10:13:36.685643 line        10         lst.append(random.randrange(1, 1000))
Modified var:.. lst = [94, 204, 81, 512, 830, 677, 888]
10:13:36.685643 line         9     for i in range(10):
Modified var:.. i = 7
10:13:36.685643 line        10         lst.append(random.randrange(1, 1000))
Modified var:.. lst = [94, 204, 81, 512, 830, 677, 888, 737]
10:13:36.685643 line         9     for i in range(10):
Modified var:.. i = 8
10:13:36.685643 line        10         lst.append(random.randrange(1, 1000))
Modified var:.. lst = [94, 204, 81, 512, 830, 677, 888, 737, 253]
10:13:36.685643 line         9     for i in range(10):
Modified var:.. i = 9
10:13:36.685643 line        10         lst.append(random.randrange(1, 1000))
Modified var:.. lst = [94, 204, 81, 512, 830, 677, 888, 737, 253, 224]
10:13:36.685643 line         9     for i in range(10):
10:13:36.685643 line        12     lower = min(lst)
New var:....... lower = 81
10:13:36.685643 line        13     upper = max(lst)
New var:....... upper = 888
10:13:36.686644 line        14     mid = (lower + upper) / 2
New var:....... mid = 484.5
10:13:36.686644 line        15     print(lower, mid, upper)
10:13:36.686644 return      15     print(lower, mid, upper)
Return value:.. None
Elapsed time: 00:00:00.002000

Process finished with exit code 0

 

标签:10,13,打印,pysnooper,36.685643,lst,var,line,运行
From: https://www.cnblogs.com/daizichuan/p/17488773.html

相关文章

  • java 如何实现控制台打印sql语句
    springboot项目打印sql语句2019.9.27首先我们看一下效果现在直接上代码:logback-spring.xml文件<configuration><!--%m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,%i索引【从数字0开始递增】,,,--><!--appender是configuration的子节点,是负责......
  • python unitest 测试运行器(Test Runner)
    测试运行器(TestRunner)是unittest框架提供的执行测试用例的组件,用于自动运行测试用例并生成测试结果报告。它负责加载测试用例、执行测试用例,并提供测试结果的输出。unittest框架提供了多种测试运行器,包括TextTestRunner、HTMLTestRunner、XMLTestRunner等。这些运行器可以根据不......
  • TienChin 开篇-运行 RuoYiVue
    开篇目的:让大家随心所欲的DIY若依的脚手架不会涉及到太多基础知识踊跃提问(不懂得地方大家提问我会根据提问,后续一一解答疑惑)下载RuoYiVueGitee:https://gitee.com/y_project/RuoYi-Vue下载完毕之后,这个项目当中存在一个ruoyi-ui这个是前端,只是放在了这个项目当中方便我们进......
  • 如何让UnityEditor后台运行
    最近在玩ml-agents,发现训练的时候点击别的窗口,UnityEditor就挂起不接着运行了。google了一下发现可以通过点击Edit->ProjectSettings->Player->ResolutionandPresentation,然后勾选RunInBackground即可解决该问题:......
  • TienChin 开篇-运行 RuoYiVue
    开篇目的:让大家随心所欲的DIY若依的脚手架不会涉及到太多基础知识踊跃提问(不懂得地方大家提问我会根据提问,后续一一解答疑惑)下载RuoYiVueGitee:https://gitee.com/y_project/RuoYi-Vue下载完毕之后,这个项目当中存在一个ruoyi-ui这个是前端,只是放在了这个项目当中方便我们进......
  • 【剑指Offer】19、顺时针打印矩阵
    【剑指Offer】19、顺时针打印矩阵题目描述:输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下4X4矩阵:12345678910111213141516则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10.解题思路:由于是按照从外到内的顺序依次打......
  • 【算法题】斜着打印矩阵
    //[1,2,3]//[4,5,6]//[7,8,9]//[10,11,12]////printorder1,2,4,3,5,7,6,8,10,9,11,12functiontest(){letarr=[[1,2,3],[4,5,6],[7,8,9],[10,11,12]];letsum=......
  • 运行python -m uiautomator2 init报错AttributeError: module 'collections' has no a
    报错信息:Traceback(mostrecentcalllast):File"E:\Carte\BB\17-SiteLeadership\alte\IonelBalauta\Aryeht\Task1-Traducetotsite-ul\DoarGoogleWeb\Andreea\Meditatii\Sedinta9(2022)(EMAIL)\BEBE-PARSING-Python(fararedenumire2).p......
  • Jenkins-Slave节点 电脑A控制电脑B运行Python脚本
    电脑A装了Jenkins的服务器,电脑B作为Jenkins的节点电脑(Slave)Jenkins服务的配置1、ManageJenkins>ConfigureSystem 找到JenkinsURL,确保不是127.0.0.1或者localhost就可以了。 2、ManageJenkins>ConfigureGlobalSecurity找到代理,设置端口或者选择随机选取,再把代......
  • 2、【java程序运行监控byteman】使用示例(运行中方法耗时监控、javaagent监控、jvm监控
    (文章目录)本文介绍了byteman的其他几种应用场景及示例,比如javaagent、监控jvm、bmjava命令、如何查看运行的规则、检查规则的正确性、检查规则是否在运行中等。本文分为2个部分,即运行中方法耗时监控和其他示例。一、统计方法耗时(程序运行中)该类是实时显示控制台输入的结果以......