python中从元组到浮点的格式?

python中从元组到浮点的格式?,python,Python,错误是: def tong_thoigian (self,kr,uid,ids,context={}): obj=self.browse(kr,uid,ids,context=context)[0] kr.execute('''select name,giolam from x_giolam where name=%s'''%(obj.ma_luong)) kq=kr.fetchall() tong=0.00000 for i in kq:

错误是:

def tong_thoigian (self,kr,uid,ids,context={}):
    obj=self.browse(kr,uid,ids,context=context)[0]
    kr.execute('''select name,giolam from x_giolam where name=%s'''%(obj.ma_luong))
    kq=kr.fetchall()
    tong=0.00000
    for i in kq:
          tong+=kq[1]                      
    self.write(kr,uid,ids,{'tonggiolam':tong},context=context)
我想你不在乎表格和数据库。。。。因为在表
x_giolam
中表示get mayny row的函数有atribute
giolam
并求和…然后我们就有了员工的工资。

因为查询是“select name,giolam…”,kq可能类似于:

TypeError: unsupported operand type(s) for +=: 'float' and 'tuple'
所以我想你想要:

[ ('Thong', 324.34), ('Tran', 543.34), ('Thang', 765.52) ... ]
由于查询是“选择名称,giolam…”,kq可能类似于:

TypeError: unsupported operand type(s) for +=: 'float' and 'tuple'
所以我想你想要:

[ ('Thong', 324.34), ('Tran', 543.34), ('Thang', 765.52) ... ]

你是指
tong+=kq[1]
而不是
tong+=kq[1]
吗?你是指
tong+=kq[1]
而不是
tong+=kq[1]