Python创建结构体和类数组Pygame的精灵类看的头疼,就⼲脆把类当C的结构体⽤ # 使⽤类创建结构体
class Bullet(object):
中药制剂class Struct(object):
def __init__(self, x, y, L):
self.x = x
self.y = y
2018未来科学大奖self.L = L
def make_struct(self, x, y, L):
self.x = x
self.y = y
self.L = L
return self.Struct(x, y, L)
bullet = Bullet()
bullet1 = bullet.make_struct('123', '0', '0')太仓实验高级中学
print(bullet1.x)停电宝
#初始化类数组做一个善读者作文
荣乌高速车祸bullet_N=[Bullet() for i in range(1,32)]
for i in range(1,31):
bullet_N[i].x=i
print(bullet_N[i].x)