zoukankan      html  css  js  c++  java
  • python第三方库

    nnlog模块

    事对logging写日志操作进行了封装,使用起来更方便。该模块是第三方模块,需要先安装并导入

    log = nnlog.Logger(file_name='my1.log', level='debug', when='D', backCount=5, interval=1)
    # file_name是日志文件名
    # level是日志级别,如果不传的话默认是debug级别
    # when是日志文件多久生成一个,默认是按天,S 秒、M 分、 H 小时、 D 天、 W 每星期
    # backCount是备份几个日志文件,默认保留5天的
    # interval是间隔多久生成一个日志文件,默认是1天
    log.debug('默认日志级别是debug')
    log.info('info级别')
    log.warning('waring级别')
    log.error('error级别')

    urllib.parse模块

    url.parse :定义了url的标准接口,实现url的各种抽取
    parse模块的使用:url的解析,合并,编码,解码
    使用时需导入

    from urllib import parse

    urlparse()实现URL的识别和分段

    urlunparse()可以实现URL的构造

    urljoin()传递一个基础链接,根据基础链接可以将某一个不完整的链接拼接为一个完整链接

    urlencode()将字典构形式的参数序列化为url编码后的字符串

    quote()可以将中文转换为URL编码格式

    yagmail
    https://github.com/kootenpv/yagmail
    import yagmail
    yag = yagmail.SMTP()
    contents = ['This is the body, and here is just text http://somedomain/image.png',
                'You can find an audio file attached.', '/local/path/song.mp3']
    yag.send('to@someone.com', 'subject', contents)
    
    
    dir = '/Users/yixia/PycharmProjects/statuscode/report/'
    lists = os.listdir(dir)
    lists.sort(key=lambda fn:os.path.getmtime(dir+'//'+fn))

    file_new = os.path.join(dir,lists[-1])
     

    BeautifulReport

     https://github.com/TesterlifeRaymond/BeautifulReport

    from BeautifulReport import BeautifulReport

      

    result = BeautifulReport(测试集)

    result= report(filename='测试报告', description='搜索测试', log_path='.')    #log_path='.'把report放到当前目录下


    pandas 数据处理

    使用pandas处理sqlexcel数据
    pd.read_excel('路径',heaer, index_col, usecols,等)

     
    class ConnectSQL():

    def __init__(self,host,port,user,password,db):
    self.host=HOSTS
    self.port=PORT
    self.user=USERS
    self.password=PASSWORDS
    self.db=DB

    def connectsql(self):

    try:
    connect = pymysql.connect(host=self.host,port=self.port,user=self.user,password=self.password,db=self.db,charset='utf8')
    cursor = connect.cursor(pymysql.cursors.DictCursor) #以字典形式显示数据,默认是元组
    res = cursor.execute('select code from t_status_code where code=500')
    print(res)

    print(cursor.fetchall())
    cursor.close()
    connect.close()
    except Exception as e:
    print(e)
     
  • 相关阅读:
    开源项目:MMTweenAnimation
    URI跳转方式地图导航的代码实践
    处理i18n国际电话区号的代码实践
    图片变形的抗锯齿处理方法
    CocoaPods版本升级
    JSPatch 部署安全策略
    JSPatch实现原理详解<二>
    JSPatch实现原理详解
    JSPatch – 动态更新iOS APP
    iOS富文本组件的实现—DTCoreText源码解析 渲染篇
  • 原文地址:https://www.cnblogs.com/bibizhou/p/12273394.html
Copyright © 2011-2022 走看看