亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標題: python類的問題 [打印本頁]

作者: kellyseeme123    時間: 2015-09-10 10:10
標題: python類的問題
剛學(xué)python,問個簡單問題
我定義了一個類,那么我怎么引用呢?
  1. [root@python testclass]# ls -l
  2. total 8
  3. -rw-r--r-- 1 root root  38 Sep 10 02:08 test.py
  4. -rw-r--r-- 1 root root 270 Sep 10 02:09 test.pyc
  5. [root@python testclass]# cat test.py
  6. #!/usr/bin/python
  7. class person:
  8.         pass
  9. [root@python testclass]# python
  10. Python 2.6.6 (r266:84292, Sep 12 2011, 14:03:14)
  11. [GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
  12. Type "help", "copyright", "credits" or "license" for more information.
  13. >>> p=person()
  14. Traceback (most recent call last):
  15.   File "<stdin>", line 1, in <module>
  16. NameError: name 'person' is not defined
  17. >>> import test
  18. >>> p=person()
  19. Traceback (most recent call last):
  20.   File "<stdin>", line 1, in <module>
  21. NameError: name 'person' is not defined
  22. >>> import test.py
  23. Traceback (most recent call last):
  24.   File "<stdin>", line 1, in <module>
  25. ImportError: No module named py
復(fù)制代碼

作者: kellyseeme123    時間: 2015-09-10 10:16
已經(jīng)解決。。p = test.person()
即可。。。。。
作者: huang6894    時間: 2015-09-10 15:35
import test 而不是import test.py




歡迎光臨 Chinaunix (http://www.72891.cn/) Powered by Discuz! X3.2