Files
freeCodeCamp/guide/arabic/python/exception-and-error-handling/index.md
Randell Dawson d6a160445e Convert single backtick code sections to triple backtick code sections for Arabic Guide articles (13 of 15) (#36240)
* fix: converted single to triple backticks13

* fix: added prefix

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: removed language in wrong place

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: add language postfix

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: removed language in wrong place

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>
2019-06-20 18:07:24 -05:00

1.3 KiB

title, localeTitle
title localeTitle
Exceptions and Errors Handling الاستثناءات ومعالجة الأخطاء

الاستثناءات ومعالجة الأخطاء

عند إنشاء برنامج ، يمكننا ارتكاب الأخطاء التي تنتهي بالأخطاء ، وأسوأ البرامج التي نجعلها تتوقف عن العمل ، سيكون الأمر مزعجًا أكثر إذا لم نتمكن من العثور على أخطاء في الشفرة التي قمنا بها أو ما هو الخطأ. بكلمات بسيطة ، الأخطاء هي شيء يتجنبه المبرمجون في صنع برنامج. لحل هذه المشكلة في python يمكننا استخدام try except

مثال:

>>> try:
>>> . . . print "this is not a string "+1
>>> except:
>>> . . . print "error"
error

وإذا كنت ترغب في الحصول على رسائل خطأ بمزيد من التفاصيل من التعليمات البرمجية ، فيمكنك إضافة وسائط except Exception as err

>>> try:
>>> . . . print "this is not a string "+1
>>> except Exception as err:
>>> . . . print "error:\n"+str(err)
error:
cannot concatenate 'str' and 'int' objects

معلومات اكثر:

وثائق الأخطاء والاستثناءات.