2017-04-17 75 views
-3
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”功能的第二行,我不知道什么是错的。任何帮助将非常感激。蟒蛇的范围和对象的一些麻烦

+3

你是什么意思“有问题”?究竟是什么问题? – BrenBarn

+0

什么是错误?,我试过你的代码,我没遇到问题。 – eyllanesc

回答

-2

我认为添加somthing可能会解决您的问题。

if __name__ =="__main__": 
     doTheThings() 

因为这是python代码的访问。

+0

“因为这是Python代码的访问。”,不,它并不总是如此。 – abccd