我已签出答案,但无法解决“预期缩进块”的问题]]

问题描述 投票:-1回答:1

我有这样的代码,但出现错误“预期缩进的块”event =此行的事件(int(splitted [0]),int(splitted [1]),int(splitted [2]),int(splitted [3]),splitted [4] .lower())。我是python的新手,所以无法弄清楚到底发生了什么。请

 class Events:          ## arama ve sms classı (user arama ya da sms oluşturduğunda listeye girecek olan objeler buradan üretilecek)
        callduration = 0
        def __init__(self, PhoneNo, Year, Month, Day, Type):
            self.PhoneNo = PhoneNo
            self.Year = Year
            self.Month = Month
            self.Day = Day
            self.Type = Type
    class User:
        EventsList = []   ## event objelerinin listede tutulması
        def __init__(self, PhoneNo, FName, LName):   ## user classından obje üretmek için construction
            self.PhoneNo = PhoneNo
            self.FName = FName
            self.LName = LName
            self.Credit = 100
            self.Smscounter = 0

        def Add(self):   ## Add fonksiyonu
            print("Add Event with comma for example : PhoneNo,Year,Month,Day,Type(SMS OR CALLING)")
            print("PhoneNo,Year,Month,Day,Type(SMS OR CALLING)")
            eventInput = input()
            splitted = eventInput.split(",")   ## Virgüllerin Split işlemi arraya atılması

            if len(splitted) == 5:
                try:

                event = Events(int(splitted[0]), int(splitted[1]), int(splitted[2]), int(splitted[3]),splitted[4].lower())
                if event.Type == "sms":   ## SMS kontrolü
                    if(self.Credit != 0):
                        self.Credit = self.Credit - 1  ## Credittten Düşme
                    self.Smscounter = self.Smscounter + 1
                    print("\n ~~~~~~Call/Sms Added~~~~~ \n")
                    self.EventsList.append(event)

                elif event.Type == "call":  ## Arama Kontrolü
                    print("Call duration in minute ?")
                    duration = input()
                    event.callduration = int(duration)   ## Arama dakikası inputu alma
                    print("\n ~~~~~~Call/Sms Added~~~~~ \n")
                    self.EventsList.append(event)
            else:
                print("Wrong Input!")


                    except Exception:
                        print("Wrong Input")

                    else:
                        print("Wrong Input!")

我有这样的代码,并且出现错误“预期缩进的块” event = Events(int(splitted [0]),int(splitted [1]),int(splitted [2]),int(splitted [3]),为此行分割为[4] .lower())。我是...

python-3.x
1个回答
0
投票

这是您的代码的正确版本:

热门问题
推荐问题
最新问题