from tinydb import TinyDB, Query
db = TinyDB('db.json')
ddd = Query()
kl = free
output = db.search(ddd.state == 'free')
如何在tinydb db.search中使用变量 k1 ?
答案 0 :(得分:0)
只需在#!/usr/bin/gnuplot
set term png font ",18" enh size 1000,1000
set view map
unset surface
set contour base
set cntrparam level incremental 0.005, 0.02, 0.5
set key at screen 1, 0.9, 0
set rmargin 0.50
#
a=6.3457
set xra[0.:2.60*a]
set yra[0.:1.73*a]
set xtics out nomirror
set ytics axis in offset -4.0,0 nomirror
set label "r (a.u)" at 3.4,-2.2 center
set label "r (a.u)" at -1.7,2.5 rotate by 90 center
set out 'M.1.-1.112.3.888.png'
splot 'M.1.-1.112.3.888.dat' u 1:2:3 w l lw 2 t ''
db.search
输出
from tinydb import TinyDB, Query
db = TinyDB('db.json')
ddd = Query()
db.insert({'state': 'free', 'field': 1})
db.insert({'state': 'n', 'field': 2})
db.insert({'state': 'free', 'field': 3})
kl = 'free'
output = db.search(ddd.state == kl)
print(output)