-2
我在Windows 10爲什麼當我的班級打電話給我的班級工作時,需要兩個參數?
下運行的Python 3.3.4是我的課代碼 -
class Curl():
def __init__(self):
self.file7 = file7
self.Days1 = Days1
def readfile(self):
ticknum = 0
read_ticker = []
ins = open(file7, "r")
for line in ins:
if line.endswith('\n'):
line=line[:-1]
read_ticker.append(line)
ticknum =+1
ins.close()
return read_ticker
def CalcDates(self, Days1): # Determine dates
calculated_dates = dict()
Run_Time = (time.strftime("%H/%M/%S"))
calculated_dates['Run_Time']= Run_Time
Today = date.today()
calculated_dates['Today'] = Today
End_Date = (Today - timedelta(days=Days1))
calculated_dates ['Start_Date'] = Today
Start_Day = str(Today.strftime("%d"))
calculated_dates['Start_Day'] = Start_Day
Start_Month = str(Today.strftime("%m"))
calculated_dates['Start_Month'] = Start_Month
Start_Year = str(Today.strftime("%Y"))
calculated_dates['Start_Year']= Start_Year
End_Day = str(End_Date.strftime("%d"))
calculated_dates['End_Day'] = End_Day
End_Month = str(End_Date.strftime("%m"))
calculated_dates['End_Month']= End_Month
End_Year = str(End_Date.strftime("%Y"))
calculated_dates['End_Year']= End_Year
return calculated_dates
它運行,如果我做了以下內容:
file7 = 'C:\\...\\file1.txt'
fileList = Curl.readfile(file7)
print('readTickers is complete')
print(fileList)
D1 = Curl.CalcDates(90, 90)
print(D1)
我希望它運行,如果我改變行D1如下; D1 = Curl.CalcDates(90)
但它沒有 - 我得到以下錯誤;
Traceback (most recent call last):
File "C:\Users\Edge\Desktop\readTICKR class432.py", line 56, in <module>
D1 = Curl.CalcDates(90)
TypeError: CalcDates() missing 1 required positional argument: 'Days1'
爲什麼當我打電話給Curl.CalcDates時需要雙重爭論?
我該如何解決這個問題,以便我可以使用一個單獨的論證?