🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 55 (from laksa152)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
4 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.2 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://tutorial.eyehunts.com/python/python-print-exception-message/
Last Crawled2026-04-12 14:01:44 (4 days ago)
First Indexed2022-12-30 03:48:53 (3 years ago)
HTTP Status Code200
Meta TitlePython Print exception message
Meta DescriptionThe most common method to catch and print the exception message in Python is using try-except statements. If You want to save an error...
Meta Canonicalnull
Boilerpipe Text
The most common method to catch and print the exception message in Python is using try-except statements. If You want to save an error message then use the logger.exception() method. This method produces an error message as well as a log trace. It contains information such as the code line number at which the exception occurred and the time the exception occurred. Simple example code catch and prints The Exception Messages In Python. list_arr = [10, 20, 30, "5f", "7k", 78, 88] for elem in list_arr: try: print("Result: ", elem / 9) except Exception as e: print("Exception occurred for value '" + elem + "': " + repr(e)) Output: Using try and logger.exception to print an error message import logging logger = logging.getLogger() num1 = 1 num2 = 0 try: print("Result: ", num1 / num2) except Exception as e: logger.exception("Exception Occured while code Execution: " + str(e)) Output: Exception Occured while code Execution: division by zero Traceback (most recent call last): File "C:\Users\Rohit\PycharmProjects\pythonProject\modules\main.py", line 9, in <module> print("Result: ", num1 / num2) ZeroDivisionError: division by zero Do comment if you have any doubts or suggestions on this Python exception-handling topic. Note: IDE:  PyCharm  2021.3.3 (Community Edition) Windows 10 Python 3.10.1 All  Python Examples are in Python 3 , so Maybe its different from python 2 or upgraded versions.
Markdown
[Skip to content](https://tutorial.eyehunts.com/python/python-print-exception-message/#content) [Tutorial By EyeHunts](https://tutorial.eyehunts.com/) - [EyeHunts.com](https://eyehunts.com/) - [Java](https://tutorial.eyehunts.com/java-tutorial/) - [Python](https://tutorial.eyehunts.com/python-tutorial/) - [Android](https://tutorial.eyehunts.com/android-tutorial/) - [Tutorial](https://tutorial.eyehunts.com/) - [Andriod](https://tutorial.eyehunts.com/android-tutorial/) - [JAVA](https://tutorial.eyehunts.com/java-tutorial) - [Python](https://tutorial.eyehunts.com/python-tutorial/) - [Contact US](https://eyehunts.com/contact-us/) - [Interview Puzzle](https://tutorial.eyehunts.com/top-interview-puzzle-questions-for-software-developers/) [Tutorial By EyeHunts](https://tutorial.eyehunts.com/) Navigation Menu Navigation Menu - [EyeHunts.com](https://eyehunts.com/) - [Java](https://tutorial.eyehunts.com/java-tutorial/) - [Python](https://tutorial.eyehunts.com/python-tutorial/) - [Android](https://tutorial.eyehunts.com/android-tutorial/) - [Tutorial](https://tutorial.eyehunts.com/) - [Andriod](https://tutorial.eyehunts.com/android-tutorial/) - [JAVA](https://tutorial.eyehunts.com/java-tutorial) - [Python](https://tutorial.eyehunts.com/python-tutorial/) - [Contact US](https://eyehunts.com/contact-us/) - [Interview Puzzle](https://tutorial.eyehunts.com/top-interview-puzzle-questions-for-software-developers/) # Python Print exception message - by [Rohit](https://tutorial.eyehunts.com/author/rohit/ "Posts by Rohit") - December 30, 2022 The most common method to catch and print the exception message in Python is using [try-except](https://tutorial.eyehunts.com/python/nested-try-except-python/) statements. If You want to save an error message then use the **logger.exception()** method. This method produces an error message as well as a log trace. It contains information such as the code line number at which the exception occurred and the time the exception occurred. ## **Python Print exception** Simple example code catch and [prints](https://tutorial.eyehunts.com/python/python-printf-string/) The Exception Messages In Python. ``` list_arr = [10, 20, 30, "5f", "7k", 78, 88] for elem in list_arr: try: print("Result: ", elem / 9) except Exception as e: print("Exception occurred for value '" + elem + "': " + repr(e)) ``` **Output:** ![Python Print exception](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI3NTUiIGhlaWdodD0iMzUzIiB2aWV3Qm94PSIwIDAgNzU1IDM1MyI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2NmZDRkYiIvPjwvc3ZnPg==) **Using try and logger.exception to print an error message** ``` import logging logger = logging.getLogger() num1 = 1 num2 = 0 try: print("Result: ", num1 / num2) except Exception as e: logger.exception("Exception Occured while code Execution: " + str(e)) ``` **Output:** ``` Exception Occured while code Execution: division by zero Traceback (most recent call last): File "C:\Users\Rohit\PycharmProjects\pythonProject\modules\main.py", line 9, in <module> print("Result: ", num1 / num2) ZeroDivisionError: division by zero ``` Do comment if you have any doubts or suggestions on this [Python exception-handling](https://tutorial.eyehunts.com/python/python-throw-exception/) topic. > **Note:** IDE: [PyCharm](https://www.jetbrains.com/pycharm/) 2021.3.3 (Community Edition) > > Windows 10 > > **Python 3.10.1** > > All **Python Examples are in Python 3**, so Maybe its different from python 2 or upgraded versions. ### Share this: - [Click to share on Facebook (Opens in new window) Facebook](https://tutorial.eyehunts.com/python/python-print-exception-message/?share=facebook) - [Click to share on WhatsApp (Opens in new window) WhatsApp](https://tutorial.eyehunts.com/python/python-print-exception-message/?share=jetpack-whatsapp) - [Click to share on LinkedIn (Opens in new window) LinkedIn](https://tutorial.eyehunts.com/python/python-print-exception-message/?share=linkedin) - [More](https://tutorial.eyehunts.com/python/python-print-exception-message/) - [Click to share on X (Opens in new window) X](https://tutorial.eyehunts.com/python/python-print-exception-message/?share=twitter) - [Click to print (Opens in new window) Print](https://tutorial.eyehunts.com/python/python-print-exception-message/#print?share=print) - [Click to share on Reddit (Opens in new window) Reddit](https://tutorial.eyehunts.com/python/python-print-exception-message/?share=reddit) - [Click to share on Tumblr (Opens in new window) Tumblr](https://tutorial.eyehunts.com/python/python-print-exception-message/?share=tumblr) - [Click to share on Pinterest (Opens in new window) Pinterest](https://tutorial.eyehunts.com/python/python-print-exception-message/?share=pinterest) - [Click to share on Pocket (Opens in new window) Pocket](https://tutorial.eyehunts.com/python/python-print-exception-message/?share=pocket) - [Click to share on Telegram (Opens in new window) Telegram](https://tutorial.eyehunts.com/python/python-print-exception-message/?share=telegram) - [Click to email a link to a friend (Opens in new window) Email](https://tutorial.eyehunts.com/cdn-cgi/l/email-protection#e7d89492858d828493dac2d2a5b48f86958283c2d5d7b7889493c2d2a3c2d5d7b79e938f8889c2d5d7b7958e8993c2d5d7829f848297938e8889c2d5d78a829494868082c1c4d7d4dfdc8588839eda8f93939794c2d4a6c2d5a1c2d5a193929388958e868bc9829e828f92899394c984888ac2d5a1979e938f8889c2d5a1979e938f8889ca97958e8993ca829f848297938e8889ca8a829494868082c2d5a1c1c4d7d4dfdc948f869582da828a868e8b) ### *Related* Tags:[Python exception](https://tutorial.eyehunts.com/tag/python-exception/ "Python exception")[Python Print](https://tutorial.eyehunts.com/tag/python-print/ "Python Print") ## Leave a Reply [Cancel reply](https://tutorial.eyehunts.com/python/python-print-exception-message/#respond) You must be [logged in](https://tutorial.eyehunts.com/shro/?redirect_to=https%3A%2F%2Ftutorial.eyehunts.com%2Fpython%2Fpython-print-exception-message%2F) to post a comment. Recent Posts - [Window Memes](https://tutorial.eyehunts.com/memes/window-memes/) - [Windows memes](https://tutorial.eyehunts.com/java/windows-memes/) - [Github Memes](https://tutorial.eyehunts.com/memes/github-memes/) - [Linux memes](https://tutorial.eyehunts.com/memes/linux-memes/) - [JavaScript const keyword \| Basics](https://tutorial.eyehunts.com/js/javascript-const-keyword-basics/) Categories - [Android](https://tutorial.eyehunts.com/category/android/) - [Android Interview Questions](https://tutorial.eyehunts.com/category/android-interview-questions/) - [Android Kotlin](https://tutorial.eyehunts.com/category/kotlin-android/) - [Android UI](https://tutorial.eyehunts.com/category/android-ui/) - [C](https://tutorial.eyehunts.com/category/c/) - [CSS](https://tutorial.eyehunts.com/category/css/) - [Data structure](https://tutorial.eyehunts.com/category/data-structures/) - [HTML](https://tutorial.eyehunts.com/category/html/) - [Info](https://tutorial.eyehunts.com/category/info/) - [Java](https://tutorial.eyehunts.com/category/java/) - [JavaScript](https://tutorial.eyehunts.com/category/js/) - [jQuery](https://tutorial.eyehunts.com/category/jquery/) - [JSON](https://tutorial.eyehunts.com/category/json/) - [Kotlin](https://tutorial.eyehunts.com/category/kotlin/) - [Material Design](https://tutorial.eyehunts.com/category/android/material-design/) - [Memes](https://tutorial.eyehunts.com/category/memes/) - [NodeJS](https://tutorial.eyehunts.com/category/nodejs/) - [Puzzle](https://tutorial.eyehunts.com/category/puzzle/) - [Python](https://tutorial.eyehunts.com/category/python/) - [SQL](https://tutorial.eyehunts.com/category/sql/) - [Tool](https://tutorial.eyehunts.com/category/tool/) - [TypeScript](https://tutorial.eyehunts.com/category/typescript/) Search Topics Archives Archives Subscribe Copyright © 2014 EyeHunts.com. All Rights Reserved [© 2014 EyeHunts. All rights reserved](https://eyehunts.com/) Copyright © 2014 EyeHunts.com. All Rights Reserved [© 2014 EyeHunts. All rights reserved](https://eyehunts.com/) ## Discover more from Tutorial Subscribe now to keep reading and get access to the full archive. [Continue reading](https://tutorial.eyehunts.com/python/python-print-exception-message/)
Readable Markdown
The most common method to catch and print the exception message in Python is using [try-except](https://tutorial.eyehunts.com/python/nested-try-except-python/) statements. If You want to save an error message then use the **logger.exception()** method. This method produces an error message as well as a log trace. It contains information such as the code line number at which the exception occurred and the time the exception occurred. Simple example code catch and [prints](https://tutorial.eyehunts.com/python/python-printf-string/) The Exception Messages In Python. ``` list_arr = [10, 20, 30, "5f", "7k", 78, 88] for elem in list_arr: try: print("Result: ", elem / 9) except Exception as e: print("Exception occurred for value '" + elem + "': " + repr(e)) ``` **Output:** ![Python Print exception](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI3NTUiIGhlaWdodD0iMzUzIiB2aWV3Qm94PSIwIDAgNzU1IDM1MyI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2NmZDRkYiIvPjwvc3ZnPg==) **Using try and logger.exception to print an error message** ``` import logging logger = logging.getLogger() num1 = 1 num2 = 0 try: print("Result: ", num1 / num2) except Exception as e: logger.exception("Exception Occured while code Execution: " + str(e)) ``` **Output:** ``` Exception Occured while code Execution: division by zero Traceback (most recent call last): File "C:\Users\Rohit\PycharmProjects\pythonProject\modules\main.py", line 9, in <module> print("Result: ", num1 / num2) ZeroDivisionError: division by zero ``` Do comment if you have any doubts or suggestions on this [Python exception-handling](https://tutorial.eyehunts.com/python/python-throw-exception/) topic. > **Note:** IDE: [PyCharm](https://www.jetbrains.com/pycharm/) 2021.3.3 (Community Edition) > > Windows 10 > > **Python 3.10.1** > > All **Python Examples are in Python 3**, so Maybe its different from python 2 or upgraded versions.
Shard55 (laksa)
Root Hash9754410218282928255
Unparsed URLcom,eyehunts!tutorial,/python/python-print-exception-message/ s443