读空的json文件,python2和python3 的错误提示是不一样的 python2: ValueError: No JSON object could be decoded python3: json.decoder.JSONDecodeError: Expecting value: line column () 解决: 针对python2 import json data ={"vf":"ff"} ''' #写入 with open('tmp.json',…
import os import json class SaveJson(object): def save_file(self, path, item): # 先将字典对象转化为可写入文本的字符串 item = json.dumps(item) try: if not os.path.exists(path): with open(path, "w", encoding='utf-8') as f: f.write(item + ",\n") print(&quo…