5.5.1

    1. l1=[1,2,3]
    2. l2=[100,200,300]
    3. l3=l1+l2 #组合
    4. print(l3)
    5. print([1,2,3]*4) #重复
    6. print(2 in [1,2,3]) #指定值在列表中是否在

    5.5.2
    实例:判断指定姓名再指定日期是否值班,并打对号

    1. import xlrd
    2. from xlutils.copy import copy
    3. wb=xlrd.open_workbook('值班表.xls');ws=wb.sheet_by_name('值班表')
    4. nwb=copy(wb);nws=nwb.get_sheet('值班表')
    5. row_count=ws.nrows-1
    6. n=0
    7. while n<row_count:
    8. n+=1
    9. if '岳成周' in ws.row_values(n)[1:-1]:
    10. nws.write(n,6,'√')
    11. else:
    12. nws.write(n,6,'×')
    13. nwb.save('值班表.xls')

    值班表.xls