simplejson.errors.JSONDecodeError: Expecting value: line column (char )
提示说是解码错误
可以用下面的方法判断json文件是否为空
import json
#读取
with open('tmp.json', 'r') as f:
data = f.read()
if(not bool(data)):
print("json is empty!")
但是在非空情况下会报错!!!
import json
data ={"vf":"ff"}
#写入
with open('tmp.json', 'w') as f:
json.dump(data, f)
#读取
with open('tmp.json', 'r') as f:
data = f.read()
print(data)
#判断
if(not bool(data)):
print("json is empty!")
已解决!!!https://www.cnblogs.com/sea-stream/p/10011699.html