# 1静态方法、类方法、属性方法的区别,通过代码来体现
# class Practice:
# name = "类变量"
# def __init__(self,name,age):
# self.name = name
# self.age = age
#
# @classmethod
# def user(self):
# print(self.name)
# # print(self.age)
# @staticmethod
# def s(self):
# print(self.name)
# print(self.age)
#
# @property
#
# def status(self):
# print("11")
#
# p = Practice("alex",16)
# p.user()
# p.s(p)
# p.status
# 2如何通过反射往一个类里添加一个方法?
# 3请通过代码实现反射判断当前模块里是否有一个Dog类
# import sys
# this_module = sys.modules(__name__)
# class Practice:
# name = "类变量"
# def __init__(self,name,age):
# self.name = name
# self.age = age
#
# p = Practice("alex",21)
#
# setattr(p,'show_name',lambda self:self.name)
# print(p.show_name(p))
# # setattr(p,"hobby",'bass')
# # print(p.__dict__)
# # this_module = sys.modules[__name__]
# # print(this_module)
# # print(hasattr(this_module,'dog'))
# # p2 = Practice('aa',16)
# # print(p2.__dict__)
# 4写一个小脚本,不断接收用户指令,根据指令动态导入指定模块
# __import__('__file__')
import importlib
importlib.import_module()
12-29
1396