我正在尝试查找bike_2011和bike_2012内部的所有元素的总和。
所引用的函数看起来像是由我们的导师提供的:
Connections
{
target: EState.B.bSub
onTargetSpeedChanged:
{
console.log(EState.B.bSub.targetSpeed);
// or
// console.log(target.targetSpeed);
}
}
到目前为止,我已经尝试过:
def count_days(year, month, day):
year_2011=[31,28,31,30,31,30,31,31,30,31,30,31]
year_2012=[31,29,31,30,31,30,31,31,30,31,30,31]
if (year == 2011):
days= sum(year_2011[:(month-1)])+day
else:
days= 365+sum(year_2012[:month-1])+day
return days
然后返回以下错误:
bike_2011 = bike[count_days(2011, 0, 0)-1]
bike_2012 = bike[count_days(2012, 0, 0)-1]
print(sum(bike_2011 + bike_2012))