property函數(shù)原型為property(fget=None,fset=None,fdel=None,doc=None),所以根據(jù)自己需要定義相應(yīng)的函數(shù)即可。 現(xiàn)在這個(gè)類中的x屬性便已經(jīng)定義好了,我們可以先定義一個(gè)C的實(shí)例c=C(),然后賦值c.x=100,取值y=c.x,刪除:del c.x。是不是很簡(jiǎn)單呢?請(qǐng)看第二種方法 ...
www.dbjr.com.cn/article/682...htm 2025-6-2