python模块导入
[seemmo@RegionServer1 duwen]$ python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more infORMation.
import Student
s = Student()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callablefrom Student import *
s = Student()
原因:
import module 和 from module import,区别是前者所有导入的东西使用时需加上模块名的限定,而后者不要。
可以试试:
[seemmo@RegionServer1 duwen]$ python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import Student
s = Student()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callables = Student.Student()
相关文章