python运维工程师-cmdb项目-day2

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、

 


上一篇:Python成功解决IndentationError: unindent does not match any outer indentation level


下一篇:The 14th Chinese Northeast Collegiate Programming Contest