- 论坛徽章:
- 0
|
刚学python,问个简单问题
我定义了一个类,那么我怎么引用呢?- [root@python testclass]# ls -l
- total 8
- -rw-r--r-- 1 root root 38 Sep 10 02:08 test.py
- -rw-r--r-- 1 root root 270 Sep 10 02:09 test.pyc
- [root@python testclass]# cat test.py
- #!/usr/bin/python
- class person:
- pass
- [root@python testclass]# python
- Python 2.6.6 (r266:84292, Sep 12 2011, 14:03:14)
- [GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> p=person()
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- NameError: name 'person' is not defined
- >>> import test
- >>> p=person()
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- NameError: name 'person' is not defined
- >>> import test.py
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- ImportError: No module named py
复制代码 |
|