Upcoming SlideShare
×

# اسلاید اول جلسه هفتم کلاس پایتون برای هکرهای قانونی

117

Published on

Published in: Education, Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
117
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide

### اسلاید اول جلسه هفتم کلاس پایتون برای هکرهای قانونی

1. 1. Python for Ethical Hackers Mohammad reza Kamalifard
2. 2. Python Language Essentials Part 7 : Exception Handling
3. 3. Exceptions Simply put exceptions are error condtions which disrupt the normal flow of the program Python allows for a simple and elegant way to handle exceptions >>> 0/0 Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: integer division or modulo by zero Python Standard Exceptions http://www.tutorialspoint.com/python/standard_exceptions.htm
4. 4. Exception Handling >>> try: ... print 0/0 ... except: ... print 'Exception Happened' ... Exception Happened >>> >>> try: ... print 100/10 ... except: ... print 'Exception' ... 10 >>>
5. 5. else and finally >>> try: ... print 10/2 ... except: ... print 'Exception' ... else: ... print 'No Exception' ... finally: ... print 'Cleanup code always here' ... 5 No Exception Cleanup code always here >>>
6. 6. else and finally >>> try: ... print 10/0 ... except: ... print 'Exception' ... else: ... print 'No Exception' ... finally: ... print 'Cleanup code always here' ... Exception Cleanup code always here >>>
7. 7. >>> try: ... 10/0 ... except ZeroDivisionError: ... print 'Divided by Zero' ... Divided by Zero >>>
8. 8. >>> try: ... 10/0 ... except Exception as err: ... print err ... integer division or modulo by zero >>> try: ... print name ... except Exception as err: ... print err ... name 'name' is not defined >>>