Now I'm in the Debug Python program just simply print it out in the wrong place, and don't know if Python has a single-step debugging tool like some C + + ides? Or how does the Python God debug his own Python program in general?
R
python environment variable related configurationControl Panel, System, advanced, environment variable, system variable, value in path, last line plus your X:\Python27\Scripts; X:\Python27; X:\Python27\Lib;
notepad++ Debug Run Python scripting method
This article mainly describes how to run a debug
, until the installation is successful, click to finish it. If you want to switch to a friend of the installation directory, you can change the path of the installation in that step.The third step, after the installation is complete, in our Start menu, find Python IDLE, double-click to run, you can in our IDLE, debugging our Python code.Start menu, choose the Idle (Pyth
Debug is an important debugging technique for coding, which helps developers understand the running process better by setting breakpoints during operation.Debug in Python is not as intuitive as setting breakpoints in the IDE like Java or C + +.There are two ways to debug Python: 1. Run in the command line , 2. Run in t
Let's look at debugging in Python in the following article. Learn Something
python debuggingand know how Python debugging works in Python programming.
Why do you want to debug
The probability that the program can be completed once and run normally is very small, not more th
Python Help function Debug function to get object properties and property valuesJust in touch with Python, the first Python Web program, "Getting Started with Python," is very inconvenient to debug in a simple Web server, and does
Python's own PDB library, found to use the PDB to debug the program is still very convenient, of course, what remote debugging, multithreading and so on, the PDB is uncertain.There are several ways to debug with PDB:1. Command line to start the target program, plus the-m parameter, so that the call myscript.py Word breakpoint is the execution of the first line of the programPYTHON-M PDB myscript.py2. Enabli
Microsoft's cross-platform development tool has recently been interested in Microsoft's Visual Studio code. Light weight and simplicity.Version iterations are also very fast, now nearly 1.3.1 version, the function is also more perfect.Let's briefly describe how I ran debug Python in vs code today.Because I have not seen the relevant article description on the Internet. I will find out for myself, the basic
Previously used in Windows Idel with the function of debugging a Python program, under Linux has not been debugged. (Most of the time just print) look up the Internet
Method:
Copy Code code as follows:
PYTHON-M PDB a.py
a.py is a python file.
Common commands in (PDB) mode:
QExit Debug
H is He
Now I'm in the Debug Python program just simply print it out in the wrong place, and don't know if Python has a single-step debugging tool like some C + + ides? Or how does the Python God debug his own Python program in general?Yo
Vscode is a Microsoft-developed editor that adds Python plug-ins to run Python scripts directly, or add Jupyter plug-ins with "#%%" magic to run in Python kernel after starting line annotations.If the Python,ipython is already installed, it is recommended to use the Anaconda installation package.After installing the
in the code where it is needed, as follows: 1 Import PDB 2 3 if __name__ " __main__ " : 4 A = 15 # create PDB code fragment 6 b = 27 C = A + b 8 Print (c)Enter the PDB command and view the results: 4, log, locate the problem record program operation is mainly introduced logging Library logging module provides a standard log interface, you can store various formats of the log,
Python built-in PDB library, found to use PDB for debugging
Program It is still very convenient. Of course, PDB may be confused about remote debugging and multithreading.
There are multiple ways to debug with PDB:
1. Run the command line to start the target program and add the-M parameter. In this way, if myscript. py is called, the breakpoint is before the execution of the program.Python-m pdb myscr
defmake_pie(self,ingredients):
print'******WHATISGOINGONHERE******'
printingredients
self.oven.preheat()
printself.oven.temperature
The above code is similar to debugging code? Okay, so did I. Honestly, this is not bad. Press print to run the code and see what will happen. You must flip it in the output, but you can find the desired result. At least, when you know what you want. This is usually not the case. If you know what to test, you may not need to print those outputs. Instead, yo
You can also debug a program in Python like Gcc/gdb, as long as the PDB module is introduced when you run the Python program (assuming that the program you are debugging is named d.py):
The code is as follows:
$ VI d.py#!/usr/bin/python
def main ():I, sum = 1, 0For I in Xrange (100):sum = sum + IPrint sum
if __name__
See the forum someone wrote the Java test code of the daily design, to share with you how I usually test the testThe. Code is primarily based on the Python language. Daily debugging based on Webdriver is very handy in Python interactive mode,Open Python has interactive mode:Web-side Example:
From selenium import WebdriverDr=webdriver. Chrome
', Stopbits=1, Timeout=none, xonxoff=0, rtscts=0)>>> ser.open ()>>> Ser.isopen () True>>> ser.close ()>>> ser.isopen () False4. Centralized way to read data>>> ser = serial. Serial ('/dev/ttys1', 19200, timeout=1)>>> x = Ser.read () # read one byte>>> s = ser.read (Ten) # read up to ten bytes (timeout)>>G T line = Ser.readline () # read a '/n ' terminatedline >>> ser.close ()In which, if just serial debugging, direct Ser.read (1000), this will read the value of the direct p
Tags: Linux python pdbIn Linux, you can use debugging at the interface and command line, where you record command-line debugging
At the command line, use thepython27-m pdb use_infix2postfix.py to enter debug mode
>/root/py/algor/use_infix2postfix.py (7) Import types This is the first statement of the script
H (ELP)
(Pdb) HDocumented commands (Type help =================================
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.