我收到此錯誤,當我嘗試點擊我的python項目上的按鈕時,它應該返回一個列表, nflgame當你點擊一個按鈕,但是當你點擊按鈕「ValueError:太多值解壓縮」(Python 2.7)
Traceback (most recent call last):
File "C:\Users\Developer\workspace2\test2\main.py", line 16, in methods
for(y, t, w, h, a), info in schedule_games:
ValueError: too many values to unpack
這裏是我除了GUI獨一無二的類,它只是給出了這樣的錯誤:
import sys
import nflgame
import nflgame.sched
from PyQt4 import QtGui
from window import Ui_Dialog
class Main(QtGui.QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.methods)
def methods(self):
schedule_games = nflgame.sched.games
for(y, t, w, h, a), info in schedule_games:
if y == 2013 and w == 17:
print(' VS. ')
team_home = h
team_away = a
home_game_scores_for = []
away_game_scores_for = []
home_game_scores_against = []
away_game_scores_against = []
gameHOME = nflgame.games_gen(2013, home=team_home, away=team_home, kind='REG')
gameAWAY = nflgame.games_gen(2013, home=team_away, away=team_away, kind='REG')
for g in gameHOME:
if g.home == team_home:
home_game_scores_for.append(g.score_home)
home_game_scores_against.append(g.score_away)
else:
home_game_scores_for.append(g.score_away)
home_game_scores_against.append(g.score_home)
for g in gameAWAY:
if g.home == team_away:
away_game_scores_for.append(g.score_home)
away_game_scores_against.append(g.score_away)
else:
away_game_scores_for.append(g.score_away)
away_game_scores_against.append(g.score_home)
self.ui.label.setText("AVG. Points Scored", team_home, round(sum(home_game_scores_for)/float(len(home_game_scores_for)), 1), "VS.", team_away, round(sum(away_game_scores_for)/float(len(away_game_scores_for)), 1))
self.ui.label.setText("AVG. Points Allowed", team_home, round(sum(home_game_scores_against)/float(len(home_game_scores_against)), 1), " VS.", team_away, round(sum(away_game_scores_against)/float(len(away_game_scores_against)), 1))
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
window = Main()
window.show()
sys.exit(app.exec_())
「nflgame.sched」模塊是做什麼的? –
我不確定你是否正在使用最新版本的nflgame,但是文檔中提到'nflgame.shed.games'是:「一個有序的日程數據字典,其中的遊戲按照日期排列 以及它們的時間詞典中的鍵是GSIS ID,並且 值是具有以下鍵的詞典:周,月,年, 主頁,離開,星期六,遊戲密鑰,季節類型,時間。「。見https://github.com/BurntSushi/nflgame/blob/master/nflgame/sched.py 也許這對你有幫助嗎? – gurka