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…
读空的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',…
安装pip, setuptools, and wheel 如果已经从python.org,安装啦Python 2 >=2.7.9 or Python 3 >=3.4 ,那么就已经有啦pip and setuptools, 但是需要升级到最新版本: On Linux or OS X: pip install -U pip setuptools On Windows: python -m pip install -U pip setuptools 安装protobuf pip install pr…