Как. Чтобы вызвать метод, я другой метод того же класса - PullRequest
0 голосов
/ 21 апреля 2020

я хочу использовать значения метода openfiles в используемом классе метода sanitize.i и oop подходить в следующем коде. Пожалуйста, проверьте, точен ли мой вызов, или у меня появилось больше ошибок.

import pickle
class Athlete(object):
    time1=[]
    t3=[]
    def __init__(self):
        pass
    def openfiles(self,filename):
        self.sanitize()
        self.f2=filename
        with open('C:/Users/M/Desktop/studiocode/hfpy_ch6_data/'+str(self.f2),"r") as self.f1:
            self.t1=self.f1.read()
            self.t2=self.t1.strip().split(",")
            print(self.t2)
            self.name=self.t2.pop(0)
            self.dob=self.t2.pop(0)
            self.time=self.t2            
            print("Name -:",self.name)
            print("Date of Birth -:",self.dob)
            print("Time Recorded -:",self.time)

    def sanitize(self):
        print("hi there")
        splitter=''
        print("hi1")
        if "-" in self.time:
            print("hi")
            splitter="-"
        elif ":" in self.time:
            splitter=":"
        else:
            print("hi3")
            return(self.time)
        (mins,sec)=self.time.split(splitter)
        self.t3=(mins+"."+sec)
        print("im here",self.t3)
        print(self.name)

    def top3(self):
        for self.i in self.t3:
            self.time1.append(self.i)
        print(self.time1)

b=Athlete()
x=b.openfiles("Sarah2.txt")
y=b.sanitize(x)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...