为什么循环 Tinydb.update 只是第一次在循环中工作

问题描述

tinydb 4.3.0 实际版本

from tinydb import TinyDB,Query
db = TinyDB('db.json')
    dbtable = db.table('Counters')
    Search = Query()
    splitemsg = ['','nwm','',''] #in other cases it can be different
for tableval in dbtable.all():
    for i in splitemsg:
       if i == counterfilt:
          dbtable.update({'Value': tableval['Value'] + 1},Search['Counter_filter'].any(counterfilt)) #this will add 1 to the Value in the table

我的 json 文件行:

{"_default": {},"Counters": {"1": {"Counter_name": "nwm","Counter_filter": ["nwm","nvm"],"Value": 0}}}

在此之后,它应该将 3 添加到我在 tinydb 中的表中的值,但它只是添加了 1, 为什么它不起作用? 我在循环中尝试了一些睡眠,没有用。 我试过其他版本的tinydb,没用。 如果我可以拆分字符串,我会有另一个解决方案,但分隔符是可变的,我需要保留分隔符。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)