廖雪峰python #@property使用

廖雪峰python #@property使用,第1张

概述请利用@property给一个Screen对象加上width和height属性,以及一个只读属性resolution:classScreen(object):@propertydefwidth(self):[email protected](self,value):self._width=value@propertyde

请利用@property给一个Screen对象加上wIDth和height属性,以及一个只读属性resolution:

class Screen(object):    @property    def wIDth(self):        return self._wIDth    @wIDth.setter    def wIDth(self,value):        self._wIDth=value    @property    def height(self):        return self._height    @height.setter    def height(self,value):        self._height=value    @property    def resolution(self):        return 786432
总结

以上是内存溢出为你收集整理的廖雪峰python #@property使用全部内容,希望文章能够帮你解决廖雪峰python #@property使用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1189062.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存