2015-10-15 78 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

好的,谢谢你的帮助! –

相关问题