【发布时间】:2015-04-01 10:28:22
【问题描述】:
所以我有一些名为“some_class.py”的脚本位于与 python.exe 相同的文件夹中:
from __future__ import print_function
class some_class:
def say_it(self):
print('hello')
def main():
instance = some_class()
instance.say_it()
if __name__ == '__main__':
main()
当我在 PowerShell 内的 Python Shell 中尝试使用以下命令运行它时:
some_class.py
我明白了:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'some_class' is not defined
Python 的版本是 3.4.1。我做错了什么?
【问题讨论】:
-
试试“python some_class.py”。