"关于python作用域和对象的一些问题"

2024-06-17 10:00:50 发布

您现在位置:Python中文网/ 问答频道 /正文

class Thing:
    def __init__ (self, a, b, c,):
        self.a = a
        self.b = b
        self.c = c

stuff = Thing("apples","butter","charlie")
otherThing = stuff

def doTheThings():
    if(otherThing.a == "apples"):
        print("done")

doTheThings()

我对“doTheThings”函数的第二行有问题,我不知道出了什么问题。任何帮助都将不胜感激


Tags: 函数selfifinitdefclassprintthing