Python 错误异常及代码测试

try:
print(5/3)
except 错误类型 as e1:
处理或者显示错误
except 错误类型 as e2:
处理或者显示错误
except 错误类型 as e3:
处理或者显示错误
...
except:
处理或者显示错误
else:
程序没有异常的时候执行的
finally:
无论程序执行是否出现异常都会执行的区域
在这里插入代码片

from echart import *
import unittest
class Mytest(unittest.TestCase):
def setUp(self):
self.p = potao(1,'fry','good')
def test_price(self):
self.assertEqual(1,self.p.price)
def test_cook(self):
self.assertEqual('fry',self.p.cook)
def test_cooking(self):
self.assertEqual('potao is good', self.p.cooking())
if __name__ == '__main__':
unittest.main()
>Ran 3 tests in 0.001s
>OK