I have always feel that Python's development, the biggest difficulty is the debugging section, without a good debug environment can be used, and the use of logs is not very convenient. Two days of debug cycles and tired of me. Because the number of cycles is over a thousand times, the previous few hundred cycles will not have any problems, mainly, mainly the rear processing may be wrong. I changed a few IDE debugging, it was not very cool, and finally thought of using the log mode, print each loop, recorded in a file. However, the log information provided by Python's logging is too rich, and I can easily locate simple information.
Later, I found a code from an e-book, that is, redirect the original stdout and redirect it again after completion. After using it, it feels good, the debugging information is significantly reduced, simple and convenient: -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------- Import sys ... if __name __ == '__ main__': oldstdout = sys.stdout sys.stdout = Open ("Script.log", "W ") Print Script.schoolsong (Download (Download (Download )) Sys.stdout = oldstdout --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Published on @
23:27 |
Comments and feedback (0)