列表嵌套,俗称盖中盖
c = [[1,2],[3,4],[5,6]]
l = [a for b in c for a in b]
print(l)
# [1, 2, 3, 4, 5, 6]
[a for b in c for a in b] 作用就是将盖中盖解放
下面这段的简写版
c = [[1,2],[3,4],[5,6]]
l = []
for b in c:
for a in b:
l.append(a)
print(l)
# [1, 2, 3, 4, 5, 6]
var tempDate=new Date(value.replace(/-/g,"/"));//把日期字符串转换成日期格式
var resultDate=new Date((tempDate/1000+(86400*10))*1000);//增加n天后的日期
var resultValue=resultDate.getFullYear()+"-"+(resultDate.getMonth()+1)+"-"+(resultDate.getDate());//将日期转化为字符串格式
var date= new Date();
//2把字符串格式转换为日期类
var valueDate = new Date(Date.parse(value));
var todayDate = new Date(Date.parse(today));
//var resultValuedate = new Date(Date.parse(resultValue));
for (date in selectedFromDate){
var tempDate=new Date(date.replace(/-/g,"/")) //把日期字符串转换成日期格式
var resultDate=new Date((tempDate/1000+(86400*10))*1000) //增加10天后的日期
var valueDate = new Date(Date.parse(date)) //把字符串格式转换为日期类
var todayDate = new Date(Date.parse(today))
if (valueDate > todayDate){
window.alert('尚未开课 不可维护!!')
return false
}else if(resultDate < todayDate){
window.alert('选择中有超过开课日期后10天的成绩,不可维护!')
return false
}
}
var judgeFlag = false
var selectedFromDate = []
today = this.queryParam.period
this.$refs.courseInfoTable.selection.map((item,index)=>{
selectedFromDate.push(item.study_courseinfo__from_date)
})
selectedFromDate.forEach(function(value,index,arr){
if(judgeFlag) {
return false
}
var tempDate=new Date(value.replace(/-/g,"/")) //把日期字符串转换成日期格式
var resultDate=new Date((tempDate/1000+(86400*10))*1000) //增加10天后的日期
var valueDate = new Date(Date.parse(value)) //把字符串格式转换为日期类
var todayDate = new Date(Date.parse(today))
if (valueDate > todayDate){
window.alert('尚未开课 不可维护!!')
judgeFlag = true
return false
}else if(resultDate < todayDate){
window.alert('选择中有超过开课日期后10天的成绩,不可维护!')
judgeFlag = true
return false
}
})
if(judgeFlag) {
return false
}
datetime ——》str
max_from_date = max([datetime.datetime.strftime(courseRecord_replenish['from_date'], "%Y-%m-%d")for courseRecord_replenish in courseRecord_replenishs])
str ——》datetime 再加10天
last_maintain_date = datetime.datetime.strptime(max_from_date, '%Y-%m-%d') + datetime.timedelta(days=10)