I'm using Python 2.7.14 .
When execute this,
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os
import json
def main():
path = os.path.join(os.path.dirname(__file__), 'data-creation.json')
with open(path, 'r+') as f:
json_data = json.load(f)
json.dump(json_data, path)
if __name__=='__main__':
main()
it says AttributeError: 'unicode' object has no attribute 'write' in line of json.dump(json_data, path) .
nkf -g data-creation.json
outputs ASCII, but what is wrong?
I think this is a matter of char code.