zoukankan      html  css  js  c++  java
  • 装饰器

    import time
    def wrapper(fn):
        t = 0
        def inner(*args, **kwargs):
            nonlocal t
            tt = time.time()
            if tt - t >= 10:
                t = time.time()
                return fn(*args, **kwargs)
            else:
                print("限制访问")
        return inner
    
    def wrapper_again_5(fn):
       
        def inner(*args, **kwargs):
            fn(*args, **kwargs)
            fn(*args, **kwargs)
            fn(*args, **kwargs)
            fn(*args, **kwargs)
            fn(*args, **kwargs)
        return inner
    # from types import FunctionType, MethodType
    # isinstance()
    #
    # format(192, "08b")
    
    # @wrapper
    # def func():
    #     print("哈哈")
    #
    # func()
    # time.sleep(11)
    # func()
    # func()
    
    
    # nums = range(2,20)
    # for i in nums: # [2,19] # 2   [2,3,  ]
    #     nums = filter(lambda x:x == i or x % i, nums)
    #
    # # 迭代器惰性机制
    # print(list(nums))
    #
    # "".split("\")
    from collections import Counter
    
    lst = [1,2,3,3,3,3,3,4,4,4,4,1,1,1,2,2,1,6,7]
    
    c = Counter(lst)
    sum = 0
    for k, v in c.items():
        if v == 1:
           sum += k
    print(sum)
    

      

  • 相关阅读:
    MySQL开发规范与使用技巧总结
    Anaconda3(在D盘)安装jieba库具体步骤
    Python的reshape的用法
    oom和cpu负载的定位
    接口安全设计
    恍然间
    java原子类
    设计模式
    微服务
    常见的代码优化
  • 原文地址:https://www.cnblogs.com/LMTlmt/p/11553709.html
Copyright © 2011-2022 走看看