包含dict,text,datetime和ints的JSON转储大列表给出"TypeError:'str'不支持缓冲区接口"

slo*_*ant 6 python string json typeerror

在Windows 7 64位上使用Python 3.2 64位.

f = open("raw_data/results.json", "wb")
json.dump(dictio, f)
f.close()
Run Code Online (Sandbox Code Playgroud)

给出错误:

Traceback (most recent call last):
  File ".\calc_stats_friendly_data.py", line 22, in <module>
    main()
  File ".\calc_stats_friendly_data.py", line 18, in main
    json.dump(races, f)
  File "C:\Python32\lib\json\__init__.py", line 179, in dump
    fp.write(chunk)
TypeError: 'str' does not support the buffer interface
Run Code Online (Sandbox Code Playgroud)

我不知道出了什么问题.使用泡菜工作正常!但我必须使用JSON ...找到问题的提示?名单很大.用pickle保存它需要56 MB.

Ry-*_*Ry- 17

你正在打开二进制文件的文件."w"仅使用模式打开它.