Python中类的定义和使用
类的定义:
class Patrolcar(): def __init__(self,pcar_ip,pnow_x,pnow_y,pnow_direction,pfuture_x,pfuture_y,pfuture_direction,pIsUp,pIsLife,pcar_speed,pcar_MAC): self.car_ip=pcar_ip self.now_x=pnow_x self.now_y=pnow_y self.now_direction=pnow_direction self.future_x=pfuture_x self.future_y=pfuture_y self.future_direction=pfuture_direction self.IsUp=pIsUp self.IsLife=pIsLife self.car_speed=pcar_speed self.car_MAC=pcar_MAC
类的创建和使用:
car1 = Patrolcar(123, 0, 0, 1, 2, 2, 3, 0, 0, 140, 456) print(car1.car_ip, end='')