-1
任何人都可以解釋爲什麼我在has_happened()
方法中得到return
語句的語法錯誤。在類內使用return時的語法錯誤
from sys import argv
import time
from datetime import date
class Game(object):
def __init__(self, home, away, home_odds, away_odds, date):
self.home = home
self.away = away
self.home_odds_str = home_odds
self.away_odds_str = away_odds
self.date = date
def to_string(self):
return self.home + ", " + self.away + ", " + self.home_odds + ", " + self.away_odds + ", " + self.result + ", " + self.date
def has_happened(self):
dates_split = self.date.split("/")
today = date.today()
game_date = date(int(dates_split[2]), int(dates_split[1]), int(dates_split[0])
return str(game_date < today)
game1 = Game("t1", "t2", "7/8", "9/1", "29/9/2016")
game1.has_happened()
收盤在的括號'日期(...' –
始終顯示完整的錯誤消息。你忘了')'的'在線遊戲約會結束= ...' – furas
親切貼全追溯 –