python对象中使用重写__repr__()
方法可以实现
class Item():
url = ''
title = ''
summary = ''
category = ''
content = ''
pan = ''
publish_time = ''
thumbnail = ''
def __repr__(self) -> str:
return '\n'.join(['%s:%s' % item for item in self.__dict__.items()])