鱼C论坛

 找回密码
 立即注册
查看: 2699|回复: 3

[已解决]看代码

[复制链接]
发表于 2019-1-2 10:45:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
class C:
        def __init__(self,size =10):
                self.size = size
        def getSize(self):
                return self.size
        def setSize(self,value):
                self.size =value
        def delSize(self):
                del size.size
        x =property(getSize,setSize,delSize)
c = C()
>>> c.x
10
>>> c.x = 100
>>> c.x
100
>>> del c.x
Traceback (most recent call last):
  File "<pyshell#92>", line 1, in <module>
    del c.x
  File "<pyshell#86>", line 9, in delSize
    del size.size
NameError: name 'size' is not defined    del 为什么会报错这是啥情况
最佳答案
2019-1-2 10:48:03
本帖最后由 heidern0612 于 2019-1-2 10:49 编辑

del size.size  是个啥?  错误这么明显。


卧槽,楼上大神给力,手慢了一步
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-1-2 10:46:23 | 显示全部楼层
del self.size
写法有误

评分

参与人数 1荣誉 +5 鱼币 +5 贡献 +3 收起 理由
heidern0612 + 5 + 5 + 3 鱼C有你更精彩^_^

查看全部评分

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-1-2 10:48:03 | 显示全部楼层    本楼为最佳答案   
本帖最后由 heidern0612 于 2019-1-2 10:49 编辑

del size.size  是个啥?  错误这么明显。


卧槽,楼上大神给力,手慢了一步
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-2 10:51:47 | 显示全部楼层
BngThea 发表于 2019-1-2 10:46
del self.size
写法有误

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-23 13:31

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表