无法识别Python简单类

无法识别Python简单类,python,Python,使用Python2.7 输出: class Example: values=None s1=Example s1.values.append(1) s1.values.append(2) for x in s1.values: print x python新手,不知道为什么它不能识别简单类 以下是一个工作示例: line 8, in Example s1=Example NameError: name 'Example' is not defined enter c

使用Python2.7

输出:

class Example:
values=None

s1=Example
s1.values.append(1)
s1.values.append(2)

for x in s1.values:
    print x

python新手,不知道为什么它不能识别简单类

以下是一个工作示例:

line 8, in Example
    s1=Example
NameError: name 'Example' is not defined
    enter code here

另外,我建议您遵循一些现成的方法

首先修复缩进。正如@nuncomesesquecideti所说的:缩进对python代码至关重要,而且完全不清楚您的代码“应该”做什么。我投票结束这个问题,因为对问题至关重要的代码缩进没有修复,让它不确定OP想要做什么。当你完成缩进后,你也可以停止尝试附加到None上。`s1=Example()`应该是这样的
class Example:

    def __init__(self):
        self.values = []

s1 = Example()
s1.values.append(1)
s1.values.append(2)

for x in s1.values:
    print x