c - python中数据模型,以下两种声明方式有什么区别
怪我咯
怪我咯 2017-04-17 17:47:54
0
1
226
class SearpcClient(object):

    def call_remote_func_sync(self, fcall_str):
        raise NotImplementedError()
        
        
class RpcClientBase(SearpcClient):
    
    def __init__(self, ccnet_client_pool, service_name, retry_num=1,
                 is_remote=False, remote_peer_id='', req_pool=False):
        SearpcClient.__init__(self)
        self.pool = ccnet_client_pool
        self.service_name = service_name
        self.retry_num = retry_num
        self.is_remote = is_remote
        self.remote_peer_id = remote_peer_id
        self.req_pool = req_pool
        if self.is_remote and len(self.remote_peer_id) != 40:
            raise ValueError("Invalid remote peer id")
            
            
class User(object):
    is_staff = False
    is_active = False
    is_superuser = False
    groups = []
    org = None
    objects = UserManager()
怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(1)
阿神

简单说,一个是类数据属性,一个是对象属性。

复杂说,你需要好好看看 class 部分,下面是我整理的一些资料:

https://github.com/xuelangZF/CS_Offer/blob/master/More/Python_Class.md

还可以看 Python Cookbook:

http://python3-cookbook.readthedocs.io/zh_CN/latest/chapters/p08_classes_and_objects.html

你可能还需要点 面向对象 的常识!

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!