2015-10-15 105 views
0

我在Python編程,我不斷收到一個錯誤,當我運行代碼:預期的字符緩衝區對象錯誤

預期的字符緩衝區對象

任何想法/幫助?

enter code here`fd = open('Comments', 'w' 
with open('Comments.txt', 'w') as f: 
blockname = raw_input('what is your block? ') 
f.write(blockname) 
rating = input('Rating from 1 to 10 please! ') 
f.write(rating) 
Comments = raw_input('please write your comments on this class here ') 
f.write(Comments) 
f.write('         ') 

回答

0

變化f.write(blockname)f.write(rating)f.write(Comments)f.write(str(blockname))f.write(str(rating))f.write(str(Comments))

功能write(str)寫道:字符串 STR的文件,所以您需要將它們寫之前,你的內容轉換爲字符串。

+1

好的,謝謝你的幫助! –

相關問題