# 1.用函數實現過濾掉集合list1=[' ','hello',None,'python' ]中的空格和空值 # 2.用函數方法實現計算集合list1 = [1,2,3,4,5]中,全部元素的和 class Student: __name = "三毛" name_cls = "思茅" #print(Student.__name) #print(dir(Student)) # 私有變量的訪問 #print(Student._Student__name) def study(self): self.name = "我是實例方法裏的name" print(self.name) @classmethod def study_cls(cls): print(cls.name_cls) print("我是類方法裏的方法") @staticmethod def study_static(): print("我是靜態方法裏的方法,是與類無關的方法") #私有方法 def __study_self(self): print("我是類裏邊的私有方法") s = Student() s.study() Student.study_cls() s.study_static() Student.study_static() s._Student__study_self() ''' 如何理解面向對象: 1.萬物皆對象 面向對象是一種編程思想,是編程世界向現實世界的延伸,也就是說萬物皆可描述 2.咱們用編程語言描述世界萬物,這種思想就是對象 3.類: 1) 就是面向對象的一種表現形式 '''