I have JSON data stored in the variable data
. 我將JSON數據存儲在變量data
。 服務器
I want to write this to a text file for testing so I don't have to grab the data from the server each time. 我想將其寫入文本文件進行測試,所以沒必要每次都從服務器獲取數據。 測試
Currently, I am trying this: 目前,我正在嘗試: this
obj = open('data.txt', 'wb') obj.write(data) obj.close
And am receiving the error: 並收到錯誤: spa
TypeError: must be string or buffer, not dict
.net
How to fix this? 如何解決這個問題? code