zoukankan      html  css  js  c++  java
  • 常用工具代码

    一、字符串拼接+排序

    word='''awfesdafhjkcasadckjsdackjsadvcnksausafdsch
    '''
    b='SufhwrifjiEIJFDIEJDIej'
    list1 = list(word+b)
    while '
    ' in list1:
        list1.remove('
    ')
    list2 = sorted(list1)
    print(''.join(list2))

    二、 Python装饰器实现对异常代码进行监控

    https://www.cnblogs.com/leiziv5/p/8205580.html

    import datetime,time,random
    def make(func):
        def mak(*args,**kwargs):
            try:
                func(*args,**kwargs)
            except:
                with open('except.txt','a+') as f:
                    except_time=datetime.datetime.now()
                    f.writelines(except_time.strftime('%Y-%m-%d  %H:%M:%S')+'
    ')
                    f.close()
                with open('except.txt','rb') as m:
                    try:
                        date=m.readlines()[-5].decode('utf-8')
                        ne=(date.split('
    ')[0])
                        f1=datetime.datetime.strptime(ne,'%Y-%m-%d %H:%M:%S')
                        if (except_time-f1).seconds<6:
                            print('异常!!!fail')
                        else:
                            print('正常!')
                        m.close()
                    except:
                        print('越界代表着我们的实验是成功的')
        return mak
    @make
    def beijing(i,m):
        print(i/m)
    if __name__=="__main__":
        while True:
            f=random.choice([0,1,2,3])
            n=random.choice([0,1,2,3])
            beijing(f,n)
            time.sleep(0.3)
  • 相关阅读:
    windows性能计数器
    bootstrap2.0与3.0的区别
    prototype.js简介
    .NET生成静态页面并分页
    .net 生成 静态页面
    传统的生成静态页面
    vimrc
    nginx模块动态加载(http)
    ffmpeg --help full
    confiure
  • 原文地址:https://www.cnblogs.com/di2wu/p/10307493.html
Copyright © 2011-2022 走看看