概述
import sys
import traceback
def show():
#traceback.print_stack(file=sys.stdout)
s = traceback.extract_stack()
print '%s Invoked me!'%s[-2][2]
print "hello world"
def get_cur_info():
show()
if __name__ == '__main__':
get_cur_info()
> ./mypthon
get_cur_info Invoked me!
hello world
#######################################
import sys
import traceback
def show():
#traceback.print_stack(file=sys.stdout)
s = traceback.extract_stack()
print '%s Invoked me!'%s[-3][2]
print "hello world"
def get_cur_info():
show()
if __name__ == '__main__':
get_cur_info()
>./mypthon
<module> Invoked me!
hello world
#######################################
import sys
import traceback
def show():
traceback.print_stack(file=sys.stdout)
s = traceback.extract_stack()
print '%s Invoked me!'%s[-3][2]
print "hello world"
def get_cur_info():
show()
if __name__ == '__main__':
get_cur_info()
> ./mypthon
File "./mypthon", line 70, in <module>
get_cur_info()
File "./mypthon", line 58, in get_cur_info
show()
File "./mypthon", line 45, in show
traceback.print_stack(file=sys.stdout)
get_cur_info Invoked me!
hello world
最后
以上就是魁梧书包为你收集整理的traceback.print_stack(file=sys.stdout)与traceback.extract_stack()的全部内容,希望文章能够帮你解决traceback.print_stack(file=sys.stdout)与traceback.extract_stack()所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复