diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\270\211\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21.01.02.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\270\211\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21.01.02.py" index a80f5afd1d59414766f14f337f12f828f6560840..19fbbf2ac7bfa6e3d3acc0f6c909883a06112a41 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\270\211\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21.01.02.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\270\211\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21.01.02.py" @@ -49,9 +49,9 @@ def cool(a, b): cool(5, 10) #问题三,使用装饰器来为斐波那契函数增加缓存 -a = {} + def cache_deco(func): - global a + a = {} def wrap(n): if n not in a: a[n] = func(n) @@ -66,4 +66,3 @@ def fib(n): return fib(n - 2) + fib(n - 1) print(fib(10)) -print(a) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" new file mode 100644 index 0000000000000000000000000000000000000000..a276c066a0f726d4c8ca3920ca6b3194b15c5186 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" @@ -0,0 +1,48 @@ +#第一问 +class MyMath: + @staticmethod + def add(a, b): + return a + b + + def sub(a, b): + return a - b + + def mul(a, b): + return a * b + + def div(a, b): + return a / b + + def ediv(a, b): + return a // b + + def rem(a, b): + return a % b + + def sqrt(a, b): + return float(a ** (1 / 2)) + +print(MyMath.ediv(10,5)) + +#第二问 +class Cat: + cute_cat = True + __mycat = {"David": 2} + def __init__(self, name, age): + + self. name = name + self. __age = age + + @classmethod + def __new__(cls, *args, **kwargs): + print("猫咪真可爱") + return super().__new__(cls) + + def __str__(self): + return "名字是:%s , 年龄是:%d" % (self. name, self. __age) + + + +print(Cat. _Cat__mycat) +tom = Cat("汤姆", 30) +print(tom) \ No newline at end of file