程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

On-line debugging method of Python program

編輯:Python

1、 Program debugging

It is believed that most programmers are interested in using python Language or in linux Conduct C The common debugging method for language program programming is printf, This is a method that everyone can reach , The first problem is to add printing information , see log Record . For products deployed outside , Is not a good way . However, compared with the method of online debugging, this method can obtain less information , Analyzing problems is not so fast .

2、 Online debugging

python It supports online debugging , Perhaps the relevant books do not introduce this too much , It makes me think that it can't be debugged online . Just last week I met a QT After the interface program runs for a long time, the interface is stuck , To find the cause of the problem , I just thought of online debugging , A check found that QT It really supports online debugging . So how to use online debugging ,python The native IDE It supports online debugging , The code compiler I use vscode Software ,vscode Software based on python The debugger provides friendly interface support , The experience is better . I'll just use vscode Online debugging has been carried out . Here's the picture , Open the program and select the upper right corner Debug Python File It's ready to run .

After entering the debugging interface , The left window shows the variables that the program runs , call Stack , The breakpoint , If you need to stop observing data at a specific code location , Click before the line number , Just make a red dot .

3、 solve the problem

      Use the method of online debugging , Running software 4 Hours , Found out QT Software interface stuck , The program is in a while You can't get out of the loop , Here's the picture . When pos = -1 when ,while The loop cannot exit , Find the problem , It's easy to solve the problem .

 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved