2015-10-23 135 views
1

下面的代码是给我下面的错误: TypeError: unsupported operand type(s) for +: 'int' and 'Row'类型错误:不支持的操作类型蟒蛇的web2py

import datetime 
#product withholding in days 
days = (0) 

pdays = db(db.product.withholding_period>0).select().first() 

wdate = db(db.stock_task.completed_date>0).select().first() 

fdate = wdate + datetime.timedelta(days+pdays) 

谁能解释是什么原因导致这个错误,以及如何解决?

+0

你的问题是什么? – br3w5

+0

是什么导致它 – user3502263

回答

1

错误是因为您正在尝试合计days(这是int)和pdays(这是Row)。 +运算符不适用于这两种类型的参数

+0

所以我需要的pdays的价值? – user3502263

0

您不能将数据库行添加到int。您需要从行中的正确列中提取pdayswdate。将以下列名替换为表中正确的列名:

import datetime 

product withholding in days 

days = (0) 

# get the pdays 
pdays_row = db(db.product.withholding_period>0).select().first() 
pdays = pdays_row.withholding_period 

# get the wdate 
wdate_row = db(db.stock_task.completed_date>0).select().first() 
wdate = wdate_row.completed_ date 

fdate = wdate + datetime.timedelta(days + pdays) 
+0

给我这个错误 – user3502263

+0

() – user3502263

+0

存储wdate或pdays值的列名称是什么,以及该列的数据类型是什么? – br3w5

相关问题