1、捕获异常信息
import traceback
def disk():
int('saaa')
def run():
try:
disk()
except Exception:
ret=traceback.format_exc()
print(ret)
run()
2、约束类
import abc
class Person(metaclass=abc.ABCMeta):
@abc.abstractmethod
def talk(self):
print('xx')
class Chinese(Person):
pass
p=Chinese()
TypeError: Can't instantiate abstract class Chinese with abstract methods talk
3、
4、
5、
6、