Python basics learn second bullet class properties and instance properties

  • 2020-04-02 09:36:13
  • OfStack

 
#!/usr/bin/env python 
class Foo(object): 
x=1 
if __name__=='__main__': 
foo = Foo() 
print 'foo.x=',foo.x 
print 'Foo.x=',Foo.x 
foo.x = 2 
print 'foo.x=',foo.x 
print 'Foo.x=',Foo.x 

Related articles: