python获取属性和为获取的属性赋值

动态属性名
为获取的属性赋值
setattr(self.ui, f’text_item{text_index}_flag’, 111)
调用获取对象的方法
label = getattr(self.ui, f’text_item{text_index}_flag’)
label.setText()

猜你喜欢

转载自blog.csdn.net/yuuuuuuuk/article/details/132021889