在Python3中,我通过dict从Mysql
获取值(使用pymysql.cursors.SSDictCursor
)
但是,我将get point and display函数写入html
(Flask),它显示dict key&dict
这是我的密码
staffCrt['B'] = repo.countstaff(month['bonus'], ">", line[0])
staffCrt['S'] = repo.countstaff(month['bonus'], "<", line[0])
staffList.append(staffCrt)
countstaff()中的SQL
^{2}$函数返回dict:
{'count(point)': 15}
我试着用
staffCrt['B'].values()
但它回来了 dict_值([15])
我怎样才能只得到值“15”?在
从dict获取某个值:
基本上,
d[key] = value
dict_值:
如果您对dict
d
调用d.values()
,那么它将返回一个dict_values
对象,如果您想访问它的数据,您应该在list
中转换该对象。list(d.values())
您的问题:
那么,如果
output
是函数的返回:将返回
15
编辑:
实际上
^{pr2}$output = staffCrt['B']
所以相关问题 更多 >
编程相关推荐