3
추적 줄에 연속 줄의 모든 줄을 가져올 수 있습니까?추적에서 연속 줄의 모든 줄을 가져옵니다.
예 :
#! /usr/bin/env python
def function_with_long_name(foo, bar):
raise Exception('problem?')
function_with_long_name('very_important_value',
'meaningless_value')
출력 :가 계속 행의 마지막 행을 인쇄하는 것이
$ ./test.py
Traceback (most recent call last):
File "./test.py", line 5, in <module>
'meaningless_value')
File "./test.py", line 3, in function_with_long_name
raise Exception('problem?')
Exception: problem?
참고.
$ ./test.py
Traceback (most recent call last):
File "./test.py", line 5, in <module>
function_with_long_name('very_important_value',
'meaningless_value')
File "./test.py", line 3, in function_with_long_name
raise Exception('problem?')
Exception: problem?
가 어떻게이게 가능 :
나는 이런 식으로 뭔가를 계속 라인의 모든 라인을 가지고 싶다?
traceback
모듈을 살펴 보았지만 반환하는 값은 이미 잘 렸습니다.
예 :
#! /usr/bin/env python
import traceback
def function_with_long_name(foo, bar):
print traceback.extract_stack()
function_with_long_name('very_important_value',
'meaningless_value')
출력 :
$ ./test.py
[('./test.py', 6, '<module>', "'meaningless_value')"), ('./test.py', 4, 'function_with_long_name', 'print traceback.extract_stack()')]