python运维工程师-cmdb项目-day2
阅读原文时间:2023年07月08日阅读:1

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、