In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Python traceback how to use, I believe many inexperienced people are helpless about this, this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
list index os range
There is no specific code line, no specific error content, confused, a debug fierce as a tiger, a look unexpectedly python has a artifact. Let's introduce and mark traceback
In general, we use try for exception catching, as follows:
try:
1/0except Exception as e:
print e
However, the content of this error is also very simple. The contents printed by print are as follows:
integer division or modulo by zero
If you are an external object reference to report this error, it is estimated that you are also confused. At this time, we want to make it report to the specific line. It is recommended to use traceback here.
import tracebacktry:
1/0except Exception as e:
traceback.print_exc()
the output is
Traceback (most recent call last):
File "/xxxx/test.py", line 3, in
1/0ZeroDivisionError: division by zero
After reading the above, do you know how to use traceback in python? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.