-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorProcess.py
More file actions
54 lines (44 loc) · 1.03 KB
/
ErrorProcess.py
File metadata and controls
54 lines (44 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#tye...except...finally
try:
print('try...')
r=10/0
print('result:',r)
except ZeroDivisionError as e:
print('except:',e)
finally:
print('finally')
print('END')
try:
pass
except ValueError as e:
pass
except ZeroDivisionError as e:
print('ZeroDivisionError',e)
finally:
print('finally...')
print('END')
try:
pass
except ValueError as e:
pass
except ZeroDivisionError as e:
print('ZeroDivisionError',e)
else:
pass
finally:
print('finally...')
print('END')
#Error record
import logging
try:
pass
except Exception as e:
logging.exception(e)
#Raise Error
raise ValueError('input error')
#the following are totally acceptable in python:
#passing a string representation of an integer into int int('5')
#passing a string representation of a float into float float('5.1')
#passing a string representation of an integer into float float('5')
#passing a float into int int(5.1)
#passing an integer into float float(5)