我想编写一个程序来从列表中获取每个总和。 例如:
L = [[' 7'],[' 3',' 8'],[' 8',' ; 1',' 0']]
我想得到:
8 + 3 + 7
8 + 8 + 7
1 + 3 + 7
1 + 8 + 7
0 + 3 + 7
0 + 8 + 7
所以,我用这种方式写了我的程序:
function mytime()
{
$('.timepicker').timepicker({
minuteStep: 1,
maxHours: 24,
showMeridian: false
});
}
<div class="form-group">
<label for="OrdTime" class="col-sm-3 control-label">New Time</label>
<div class="col-sm-9">
<div class="input-group bootstrap-timepicker timepicker">
<input class="timepicker form-control" onclick="mytime()" name="OrdTime" id="timepicker1" value="<?php if($FmData['OrdTime']){echo $FmData['OrdTime'];}?>" type="text">
</div>
</div>
<div class="col-sm-9">
<div class="input-group bootstrap-timepicker timepicker">
<input class="timepicker form-control" onclick="mytime()" name="OrdTime" id="timepicker2" value="<?php if($FmData['OrdTime']){echo $FmData['OrdTime'];}?>" type="text">
</div>
</div>
</div>
但是,可能会有大量的名单。通过这种方式,我必须编写大量的for循环。有没有其他方法可以用来编写我的程序?
for x1 in L[-1]:
for x2 in L[-2]:
for x3 in L[-3]:
print (int(x1) + int(x2) + int(x3))
适用于这个问题,但有没有办法不导入任何东西来解决这个问题?