2015-11-22 54 views
-2
def write(name, finalscore, totalquestions, score, file_Object): 
    pickle.dump (str(name) + ' got ' + str(finalscore) + ' percent from ' + str(totalquestions) + ' question(s), this is ' + str(score) + ' out of ' + str(totalquestions) + '.') ,file_Object) 
    return 

這個函數有什麼問題,它在最後一個括號中出現語法錯誤。用Python定義函數的問題

我已經導入了pickle並定義了它是數學測驗的一部分的所有變量,並且我試圖將結果寫入文本文件。

btw我在做GCSE計算。

+0

有一個(在一開始 –

+0

缺少這是哪裏專 –

+0

它是和pickle.dump –

回答

0

沒有字符串連接功能增加了可讀性,你可以更容易地找到任何錯誤。例如:

def write(name, finalscore, totalquestions, score, file_Object): 
    pickle.dump ("%s got %s percent from %s questions(s), this is %s out of %s." % (name, finalscore, totalquestions, score, totalquestions), file_Object) 
    return 

也許你的功能需要更多的調整......(?返回無)