天天看點

html内容寫入到檔案中的時候出現‘TypeError: expected a character buffer object’錯誤

代碼如下:

with open('ryf.md', 'a') as f:
	f.write(content)    # content是html内容
      

原因是寫入檔案要求寫入内容是str,直接轉換成str即可,如下:

with open('ryf.md', 'a') as f:
	f.write(str(content))
      

PS:發現很多東西都忘了,部落格裡倒是還有,orz,是以記憶力不靠譜