簡體   English   中英

預期的字符緩沖區對象錯誤

[英]Expected a character buffer object error

我使用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('                                   ')

f.write(blockname)f.write(rating)f.write(Comments)更改為f.write(str(blockname))f.write(str(rating))f.write(str(Comments))

函數write(str)字符串 str寫入文件,因此您需要在寫入內容之前將內容轉換為字符串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM