- 論壇徽章:
- 0
|
剛學(xué)python,問(wèn)個(gè)簡(jiǎn)單問(wèn)題
我定義了一個(gè)類(lèi),那么我怎么引用呢?- [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
復(fù)制代碼 |
|