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