Discuss / Python / 好多一起学习的伙伴都放弃了啊。。。

好多一起学习的伙伴都放弃了啊。。。

Topic source
#!/usr/bin/env python3    #告诉Linux/OS X系统,这是一个Python可执行程序,Windows系统会忽略这个注释# -*- coding: utf-8 -*-   #按照UTF-8编码读取源代码class Screen(object):    @property    def width(self):        return self.__width    @width.setter    def width(self,value1):        if not isinstance(value1,(int,float)):            raise ValueError('屏幕宽度传入参数类型为int,float')        else:            self.__width=value1    @property    def height(self):        return self.__height    @height.setter    def height(self,value2):        if not isinstance(value2,(int,float)):            raise ValueError('屏幕长度传入参数类型为int,float')        else:            self.__height=value2    @property    def fbl(self):        return self.__width*self.__heights=Screen()s.width=1024s.height=768print(s.fbl)

  • 1

Reply