遇到大型python項(xiàng)目,如何定位問(wèn)題和監(jiān)控程序的運(yùn)行狀態(tài)是一個(gè)程序員必須掌握的技能,今天小編為你帶來(lái)python程序的單步調(diào)試方法,方便易用,簡(jiǎn)單易記!
首先你需要在所調(diào)試程序的開(kāi)頭中:import pdb 并在你的代碼行設(shè)置斷點(diǎn):pdb.set_trace()
def get_input(Data, SuiteID, CaseID, caseinfolist): global sArge sArge='' args = [] #對(duì)于get請(qǐng)求,將參數(shù)組合 if reqmethod.upper()=='GET': for j in range(0, caseinfolist[1]): if Data.read_data(SuiteID, Data.casebegin+CaseID, Data.argbegin+j) != "None": ArgValue = Data.read_data(SuiteID, Data.casebegin+CaseID, Data.argbegin+j) if '$$' in ArgValue:#走關(guān)聯(lián)分支 args = ArgValue.split('$$') #print args corvalue = Correl(args[0], args[1], args[2]) pdb.set_trace() #######這兒設(shè)置斷點(diǎn),程序運(yùn)行到此處就開(kāi)始了單步調(diào)試########### if corvalue == []: