breakpoint: # err.py Import pdb s = ' 0 ' n = Int (s) Pdb.set_trace () # Running to here will automatically pause print10/n Running the code, the program will automatically pause in Pdb.set_trace () and go into the PDB debugging environment, you can view the variable with command p, or continue with command C: $ python err.py >/users/michael/github/sicp/err.py (7) Print 10/n (PDB) P n 0 (PDB) C Traceback (most recent): File "err.py", line 7, Print
The first article is about Eclipse Built in Python development environment, the second, mainly about some configuration. First article:in the Eclipse Built in Python Development EnvironmentBodyFirst we need to understand a little bit of--eclipse as a very good development to
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
code can be automatically synced to the far end.650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/8B/wKiom1ch3fHhSfYrAANfqGMulUQ729.jpg "title=" 1077857-975808e7885b586b-1.jpg "alt=" Wkiom1ch3fhhsfyraanfqgmuluq729.jpg "/>Iv. using SSH TerminalAfter the configuration as above, the deployment function has been configured, the code can be automatically synchronized to the far end. At this point, we can use SSH Terminal for process initiation and log inspection.菜单栏==>Tools==>Deployment=
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 =================================
1. Release statementpython3.6.5django2.0.62. Open Project-settingThe debug default in setting.py is equal to true, so that if there is an error in the provider that will directly show all the configuration information of the project, then if we are deployed in a formal environment, it is too dangerousSo deploy to the formal environment, need to debug to false,allowed_hosts=[] also need to modify allowed_hos
', 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
1. Tracking program executionSimilar to Sh-xPython-m Trace--trace rsyncd.pypython-m trace--trace rsyncd.py start #也可以给脚本加参数, it is OK to run2. PDB Module debugTest code exampleImport pdb a = "AAA" Pdb.set_trace () b = "BBB" c = "CCC" final = a + B + C Print finalStart debugging: Run the script directly, will stay at Pdb.set_trace (), select N+enter can perform the current statement. After you press N+enter for the first time, you can press ENTER directly to repeat the previous
The Wing IDE has a very useful feature that allows you to view debug data values in a variety of ways when dealing with complex bugs. This feature is specifically implemented by the Watch tool:
Viewing data values
Right-click the local value in the Stack data tool when an exception occurs in printashtml. This displays the following options to view the values over time:
Watch by Symbolic Path-will cause the wing IDE to look for messages with symbolic
First, this is a Python scriptImport os;for I in range (0,20): print ("Case:" +str (i)); Print ("randoming"); Os.system ("Randomdata.exe"); Print ("Running right mod"); Os.system ("Right.exe"); Print ("Running my mod"); Os.system ("My.exe"); Print ("Checking files"); Os.system ("Check.exe" +str (i+1)); Os.system ("pause"); Os.system (order)--is equivalent to entering the order string under CMD.Put the script in the specif
always worry about is the debugging of Python, before writing C are compiled with GDB directly debugging, relaxed and happy. Now it's an interpretive program that doesn't know what to do. With log bar, sometimes is a small program, do not want to write so much code, play screen bar, sometimes the screen turned fast, but also very depressed. Today finally good, saw a useful thing,PDBmethod One: Run the python
Everything was all right before it was used, and suddenly the problem arose today. According to ctrl+b execution time results only blank, check a lot of articles are only mentioned in Chinese path, system path and so on, did not solve the problem until you see this article: http://384444165.iteye.com/blog/1798107The article mentions that Sublime Text 2 ctrl+b If it appears to run as blank, press CTRL + ' to display errors if the error is unicodedecodeerror: ' ASCII ' codec can ' t decode byte 0x
Overview
Python comes with pdb to debug code.
Set breakpoints
import
pdb
...
pdb.set_trace()
....
Common commands
Set a breakpoint for break or B
Set breakpoints
Continue or c
Continue Program Execution
List or l
View the code segment of the current row
Step or s
Go to function
Return or r
Run the code until the current function returns
] doff_reserved= Tcph[4] Tcph_length= doff_reserved >> 4Print 'Source Port:'+ STR (source_port) +'Dest Port:'+ STR (dest_port) +'Sequence Number:'+ STR (sequence) +'Acknowledgement:'+ str (acknowledgement) +'TCP Header Length:'+Str (tcph_length) h_size= IHL * 4 + tcph_length * 4data_size= Len (packet)-h_size#get Data from the packetdata =packet[data_size:]Print 'Data:'+ DataIn addition, this method supports Pf_packet, so it can be used to crawl Ethernet data directly (only the X-nix system suppo
DescriptionBelow are the conditions required to build the python2.x environment:
jdk1.7
Eclipse (version less than 4.5)
Pydev (version less than 5.0)
Eclipse and Pydev build the perfect Python development environment Windows chapter1, install PythonPython is a cross-platform language, Python from
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.