class FileIO:
file_name = "F:\CalgaryWeather.csv"
data = np.loadtxt(file_name, delimiter=',' , skiprows = 1, dtype = np.float)
class Date:
year = FileIO.data[:,0]
month = FileIO.data[:,1]
class TemperautureData:
maxTemp = FileIO.data[:,2]
minTemp = FileIO.data[:,3]
snowFall = FileIO.data[:,4]
class WeatherAnalyzer:
def getmintemp():
array1 = [TemperautureData.minTemp]
mini = np.amin(array1)
return mini
def main():
print(WeatherAnalyzer.getmintemp())
if __name__ == "__main__":
main()
The program runs but it says there is a problem with def getmintemp(): saying Method had no argument pylint(no-method-argument)[17,5]
In Python, inside a class, methods are defined like that, with the 'self' argument: https://docs.python.org/3/tutorial/classes.html
class WeatherAnalyzer:
def getmintemp(self):
array1 = [TemperautureData.minTemp]
mini = np.amin(array1)
return mini
What you want is a static method:
class WeatherAnalyzer:
@staticmethod
def getmintemp():
array1 = [TemperautureData.minTemp]
mini = np.amin(array1)
return mini
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.