In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to debug PyCharm". In daily operation, I believe many people have doubts about how to debug PyCharm. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to debug PyCharm". Next, please follow the editor to study!
As the saying goes, if you want to do good work, you must first sharpen its tools. If you want to debug AI code (usually the python language), PyCharm is a powerful tool. This article will introduce some PyCharm debugging skills to better understand the code and solve code problems.
How to install PyCharm, create new projects, files, select Project Interpreter, set breakpoints, these operations are no longer discussed, it is easy to find.
This paper mainly introduces the functions of PyCharm in debug, such as variable viewing, expression calculation, variable modification, conditional breakpoint and so on. For example, use the for loop to solve a simple problem: there are four numbers: 1, 2, 3, 4, which can form three digits that are different from each other and have no repetition?
The sample code is as follows:
For i inrange (1,5):
For j in range (1,5):
For k in range (1,5):
If (I! = k) and (I! = j) and (j! = k):
Print (I, j, k)
For example, set a breakpoint at the following location (where the mouse clicks the red dot), and the program pauses automatically after running to this location:
After pausing, the debug view appears below, the green box on the right shows the value of the current variable, and the red box shows the call stack (useful if the program fails to exit abnormally). Click the yellow box to switch to the print desk.
After the print desk is expanded, you will see an icon for ShowPython Prompt (if ipython is installed, the corresponding icon will be displayed):
After clicking, you can display the value of the variable, the expression, or directly modify the value of the variable, which will take effect during debug. Of course, the for loop variable is special and will be modified by the system in the loop after modification.
In addition, introduce several commonly used keyboard shortcuts:
-F7:Step Into, enter inside the function
-F8:step Over, run in a single step
-F9:Resume Program, continue to run to the next breakpoint
-Ctrl+Alt+L: code style can be unified quickly after code snippet is selected
-Shift+Alt+F9: choose debug or run mode for the first time, and then rerun directly Ctrl+F5.
At this point, the study of "how to debug PyCharm" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 280
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.