zoukankan      html  css  js  c++  java
  • 学习小结(7)

    1、读写excel、修改excel

        xlrd

            book = xlrd.open_workbook('xxx.xls')

            sheet = book.sheet_by_index(0)  #获取第一个sheet数据

            #sheet = book.sheet_by_name('name')

            sheet.cell(0,1).value #获取指定单元格

            row_list = sheet.row_values(row) #获取整行的数据

            col_list = sheet.col_values(col) #获取整列的数据

            sheet.nrows #获取excel里面总共有多少行

            sheet.ncols  #获取excel里面总共有多少列

        xlwt

            for row in range(5):

                for col in range(6):

                    print(col)#双层循环30次

        xlutils   修改excel

        from xlutils import copy

        book = xlrd.open_workbook('xxx.xls')

        new_book = copy.copy(book)

        sheet = new_book.get_sheet(0)

        sheet.write(0,1,xxx)

        new_book.save('xxx.xls')

    redis

        数据库

            非关系型数据库,内存

        string

        r = redis.Redis(host,password,port,db=1)

        r.set()

        r.get()

        r.keys()

        r.type()

            set k value

            get k

            delete k

            set user:huangrong 123  #key是 user:huangrong  并会自动创建一个文件夹。

            keys

            type xx

        hash  #双重嵌套字典。

            比如:{  'nhy' :{ 'sex':男}   }

            hset name sex 男

            hset name  xxx  xxx

            hget stu_info_mkk fengguifeng  #大key加小key

            hgetall stu_info_mkk  #取全部值 放入字典中

            hdel stu_info_mkk  liuyuling

        exprie  key time  #  针对所有的都可以设置失效时间

         bytes

         b'xxx'

         .decode()

       ** None type has not decode 这种错误   平常取出的byte类型  但None失效时会弹出

        None

        ''

    接口开发

        1、能mock服务,测试需要

        2、不想别人操作

    例子

    import flask,os

    server = flask.Flask(__name__)  #把当前这个python文件做为一个服务

    @server.route('/error',methods=['get']) #路由,路径

    def cmd():

             cmd = flask.request.values.get('cmd')  #接口的入参

             res = os.popen(cmd)  #执行命令

             return res.read()

    server.run(host='0.0.0.0',port=8999,debug=True) #0.0.0.0.监听所有的网卡

    # 127.0.0.1  本地本机

    # ip:port/error

  • 相关阅读:
    正则表达式的与或非
    正则中需要转义的符号
    HTTP 错误状态码讯息
    HTTP协议详解
    TCP/IP、Http、Socket的区别
    CSS样式中标点符号的作用
    HighCharts: 设置时间图x轴的宽度
    可以尝试用Google Font API来摆脱网页字体的单调 仅仅抛砖引玉
    Oracle 权限(grant、revoke)
    网站加上图标
  • 原文地址:https://www.cnblogs.com/cslw5566/p/9038247.html
Copyright © 2011-2022 走看看