当前位置:网站首页>Pycharm common functions - breakpoint debugging
Pycharm common functions - breakpoint debugging
2022-06-27 20:36:00 【I am fat tiger】
PyCharm - Breakpoint debugging
I used to write Python The program , Because there is no breakpoint debugging , So debugging always uses print( Variable ) * N Time , debug Very inefficient , often 1 I have to check this question for a long time ...
I learned it later Pycharm Breakpoint debugging , Discovery is really powerful , debug The efficiency of ! So write an article to share this skill , I hope you won't worry about debugging !
Send the debugging code first
import requests
fruit = 'watermelon'
def debug_a():
global fruit
a = 0
for i in range(100):
a += 1
fruit = 'Strawberry'
def debug_b():
c = 20
d = 30
e = 40
debug_a()
debug_c()
print(fruit)
url = "http://httpbin.org/user-agent"
res = requests.get(url)
print(res.json())
b = 0
for j in range(100):
b += 1
def debug_c():
global fruit
fruit = 'lemon'
if __name__ == '__main__':
debug_b()01
Open the debug
At present, there are 4 A breakpoint ,. The location of the break point , See the picture
After setting the breakpoint , Click the button as shown in the figure , Enter debugging mode
02
Toolbar area
Left toolbar
Top Toolbar
03
Basic debugging
First of all Variable area introduction
You can click the buttons in the figure first ( Shortcut key F8), Observe variables Data changes of variables in the region
Click on the straight F8, You can find fruit Variables will be changed after running debug_c Changes after the method , c, d, e The variables do not change .
and , The data of the variable will be at the end of each line , Use gray text to display in the back , It's very convenient to check . This completes the preliminary debugging , Is it simple !
hot tip : Lines marked with blue bars , For example debug_a, Means that this line of code has not been run yet , And about to run !
04
Advanced debugging
Now re debug , But don't F8 了 , Now press A Button debugging . In operation , You can find that you will enter debug_a Methods the internal , Now you can press C The button jumps out . Empathy , In the future, we will also enter debug_c and requests Internal code in .
Debug again , At this time, keep pressing B Button , It can be found that this time it will only enter debug_a and debug_c Methods the internal , Instead of going into requests Inside of . This is it. A Button and B Differences between buttons : During commissioning , Whether to only enter the method defined by yourself !
Now let's talk about watch The use of the zone , The first is to open watch Area button , Pictured
watch Area interface , As shown in the figure
watch The role of the zone : When variables When the zone has many variables , At this point, you can select the variable of interest to watch District
That's all Pycharm Common debugging skills , You've learned ?
边栏推荐
- Yyds dry goods counting SQL sub query
- Oracle 架构汇总
- 数据库日志
- Record a failure caused by a custom redis distributed lock
- UE4: explanation of build configuration and config
- UOS提示输入密码以解锁您的登陆密钥环解决办法
- 实现字符串MyString
- 数据仓库体系之贴源层、历史层
- The meta universe virtual digital human is closer to us | Sinovel interaction
- Mass lucky hash game system development - conflict resolution (code analysis)
猜你喜欢

【STL编程】【竞赛常用】【part 2】

元宇宙虚拟数字人离我们更近了|华锐互动

Select auto increment or sequence for primary key selection?

Explore gaussdb and listen to what customers and partners say

pfSense Plus22.01中文定制版发布

CSDN 技能樹使用體驗與產品分析(1)

The meta universe virtual digital human is closer to us | Sinovel interaction

#夏日挑战赛# OpenHarmony HiSysEvent打点调用实践(L2)

北汽制造全新皮卡曝光,安全、舒适一个不落

UE4: explanation of build configuration and config
随机推荐
数智化进入“深水区”,数据治理是关键
探秘GaussDB,听听客户和伙伴怎么说
本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献
[array]bm99 clockwise rotation matrix - simple
Web APls 阶段——第十四节——本地存储
Redis data structure
Observable, reliable: the first shot of cloudops series Salon of cloud automation operation and maintenance
可观测,才可靠:云上自动化运维CloudOps系列沙龙 第一弹
CSDN 技能树使用体验与产品分析(1)
Linux系统ORACLE 19C OEM监控管理
在开发数字藏品时,文博机构该如何把握公益和商业的尺度?如何确保文物数据的安全?
Redis cluster Series III
Redis cluster Series II
[debug] platform engineering interface debugging
[数组]BM99 顺时针旋转矩阵-简单
UOS prompts for password to unlock your login key ring solution
Redis集群
二叉树相关问题2
Univision hyperinsight: Nuggets' $16.494 billion "gold hoe" in the observable market?
[STL programming] [common competition] [Part 3]