2016-12-01 4 views
1

pdb에서 debug 명령을 사용하는 방법을 알고 싶습니다.pdb (python)에서 debug 명령을 사용하는 방법

(Pdb) help 

Documented commands (type help <topic>): 
======================================== 
EOF c   d  h   list  q  rv  undisplay 
a  cl   debug help  ll  quit  s  unt 
alias clear  disable ignore longlist r  source until 
args commands display interact n   restart step  up 
b  condition down  j   next  return tbreak w 
break cont  enable jump  p   retval u  whatis 
bt  continue exit  l   pp  run  unalias where 

Miscellaneous help topics: 
========================== 
pdb exec 
(Pdb) help debug 
debug code 
     Enter a recursive debugger that steps through the code 
     argument (which is an arbitrary expression or statement to be 
     executed in the current environment). 
(Pdb) debug print('hello') 
ENTERING RECURSIVE DEBUGGER 
> <string>(1)<module>()->None 
((Pdb)) n 
hello 
--Return-- 
> <string>(1)<module>()->None 
((Pdb)) n 
LEAVING RECURSIVE DEBUGGER 
(Pdb) 

답변

0

하자, 당신은 코드가 많습니다. 이 경우, 1 행과 2 행이 자동으로 실행되며 변수 이름을 넣어 결과를 볼 수 있으며 4 행은 실행되지 않습니다.

라인 3 결과가 나타나기를 원하는 경우 결과를 보려는 코드 또는 n을 사용하여 다음 라인으로 넘어갈 수 있습니다. 계속하려면 c이 디버깅 모드를 종료해야합니다.

+2

@Shaon에게 감사하지만 파이썬으로 디버깅하는 방법을 이해하고 있지만 이해할 수없는 하나의 명령'debug' (help 명령 참조)이 있습니다. 'debug' 명령을 사용하는 방법에 대한 예제가 있습니까? –