Home >Backend Development >Python Tutorial >python 基础学习第二弹 类属性和实例属性

python 基础学习第二弹 类属性和实例属性

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 11:27:211188browse

代码如下:


#!/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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn