python - python 使用 super() 显示所有属性
问题描述
@dataclass
class vehicle():
attributex: int
attributey: int
attributez: int
@dataclass
class Bus(vehicle):
attribute1: int
attribute2: int
attribute3: int
@dataclass
class Bike(vehicle):
attribute4: int
attribute5: int
attribute6: int
现在我想要一个代码来显示所有这样的属性:
>>> bike1 = Bike(1,2,3,4,5,6)
>>> print(bike1.show_data)
attributex: 1 attributey: 2 attributez: 3 attribute1: 4 attribute2: 5 attribute3: 6
谢谢你的帮助。
解决方案
推荐阅读
- javascript - 网络音频中的多个实例
- azure-data-factory - 提高 Azure 数据工厂的并发性
- sql - 如何根据该字段中具有重复项的表创建一个字段中没有重复项的新表?
- java - 跳过或忽略 Jackson 的 YAML 解析错误
- sql - 导入 Azure SQL 后禁用主键唯一约束
- perl - 为什么我的 Tie::IxHash 程序需要很长时间?
- ios - 在 WKWebView 中使用从网站启动的相机时在 Xamarin.Forms (iOS) 中获取 SIGABRT
- html - CSS - 如何控制固定位置
- r - 聚合多个时间序列
- python - 在 Python 中使用带有 break 语句逻辑的 any() 或 all()?