Python缩进块错误

时间:2015-06-09 20:31:27

标签: python

第4行我有一个缩进的块错误:

from SimPy.Simulation import *
from random import uniform
class Car(Process):
def init(self,id):
Process.init(self)
self.id=id
def carDriving(self,driveTime):

...

可能是什么造成的?

1 个答案:

答案 0 :(得分:4)

你必须缩进类和函数:

from SimPy.Simulation import *
from random import uniform

class Car(Process):
    def __init__(self, id):
        Process.init(self)
        self.id = id

    def carDriving(self, driveTime):
        # do something here
        pass