zoukankan      html  css  js  c++  java
  • break用法

    break用法:循环的时候,循环一次即停止

    import pymysql,xlwt
    
    FI = pymysql.connect(
       host='*',user='root',passwd='*',
       port=*,db='z*',charset='utf8'
       #port必须写int类型,
       #charset这里必须写utf8
    )
    cur = FI.cursor() #建立游标
    sql = '''select
    case left(d.name,2) when 'DD' then '*' when 'DW' then '*' when 'ZN' then '*' when 'DL' then '*' WHEN 'HB' then '*' when 'ZH' then'*'  when 'DS' then '*' when 'XS' then '*' else '研发中心' end as 所属部门,
    d.name as 项目,
    b.realname,
     a.date,
     a.consumed as 工时,
     a.work
    FROM zt_effort a
    left join zt_user b on a.account=b.account
    left join zt_dept c on b.dept=c.id
    left join zt_project d on a.project=d.id
    left join zt_task e on a.objectID=e.id
    where c.id in (35,22,1)
    and a.date >='20201226' and a.date <='20210625' and c.name='*' and a.consumed>0
    and b.realname  in ('*)
    and d.name not in  ('*')
    ORDER BY d.name,a.date'''
    cur.execute(sql)
    book=xlwt.Workbook()
    sheet = book.add_sheet('*')
    fileds=[filed[0] for filed in cur.description]#获取字段表头
    res = cur.fetchall()  #获取所有返回的结果
    for col, filed in enumerate(fileds):
        # print(col, filed)
        sheet.write(0, col, filed)
    # book.save('./user_info.xls')
    n=1
    for i in res:
        bm=i[0]
        bm=bm[0:4]
        if bm=='*':
            for j in range(len(i)):
                sheet.write(n, j, i[j])
                print(n,j,i[j])
            # break
        n+=1
    book.save(r'C:UserszzDesktop11.xls')
    

      

  • 相关阅读:
    uniapp上传图片
    vue 路由router传参,刷新丢失问题
    前端网站收藏
    uni.startPullDownRefresh 只能执行一次的解决方案
    移动端,h5页面1px 1像素边框过粗解决方案
    让WebApi支持Namespace
    Ubuntu 14.04下安装GitLab
    Ubuntu学习笔记
    淘宝订单数据转CSV
    修改SQL Server 数据库的编码
  • 原文地址:https://www.cnblogs.com/ruijie/p/14931847.html
Copyright © 2011-2022 走看看