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='')

 

posted @ 2020-03-10 10:30  小大大小  阅读(1567)  评论(0编辑  收藏  举报