0
私はこのdictionary
をアップロードしていますが、更新されていないPythonの辞書ファイルは
if os.path.exists('db/user1.json'):
with open('user1.json', 'r+') as f:
db = p1
db = json.load(f)
# increment track count
updateTrackCounts(p1,value=1.0)
#update json here
f.seek(0)
f.truncate()
json.dump(p1, f)
そして私は、この更新機能を持っている:
def updateTrackCounts(d, value=0):
for i in d:
if isinstance(d[i], dict):
updateTrackCounts(d[i], value)
elif isinstance(d[i], float):
d[i] += value
しかし、もしを別のファイル(dict
)をアップロードします(例:
output = {'user1': {u'Codex': 2.0, u'Pyramid Song': 2.0, u'Hey': 2.0}}
代わりの希望:私はで終わる
p2 = {'user1': {, u'NEW :1.0, u'Codex': 1.0, u'Pyramid Song': 1.0, u'Hey': 1.0}}
output = {'user1': {, u'NEW :1.0, u'Codex': 2.0, u'Pyramid Song': 2.0, u'Hey': 2.0}}
は、私はここで何をしないのですか?