zoukankan      html  css  js  c++  java
  • 函数、方法区别

    - 函数和方法?

    class Foo(object):
    def __init__(self):
    self.name = 'alex'
    def func(self):
    print(self.name)
    
    from types import FunctionType,MethodType
    
    obj = Foo()
    print(isinstance(obj.func,FunctionType)) # False
    print(isinstance(obj.func,MethodType)) # True
    
    print(isinstance(Foo.func,FunctionType)) # True
    print(isinstance(Foo.func,MethodType)) # False
    

      


    注意:
    方法,无需传入self参数
    函数,必须手动传入self参数

  • 相关阅读:
    02-cocoapods的安装和使用
    01-唐巧之cocoapods
    class0513(html)
    程序集
    c#面向对象
    html
    dom
    Javascript
    Jquery
    ado.net
  • 原文地址:https://www.cnblogs.com/wangbaihan/p/8052677.html
Copyright © 2011-2022 走看看