装饰器
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)