python中类的应用实例

import numpy as np

class Generate(object):
    def __init__(self):
        self.group_images()
        self.lock = figure # 这里只是把变量self.lock指向了figure这个函数,没有调用这个函数
        self.z = with_bracket()

    def group_images(self):
        print('hello')

def figure():
    print('figure')

def with_bracket():
    print('with_bracket')

x = Generate()
x.lock() # 这里才调用了figure函数

结果:

hello
with_bracket
figure

猜你喜欢

转载自blog.csdn.net/weixin_43331915/article/details/83511284