Python 官方文档:入门教程 => 点击学习
[seemmo@RegionServer1 duwen]$ pythonPython 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) [GCC 4.4.7 20120313 (Red Hat 4.4.7-
[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()
--结束END--
本文标题: python模块导入
本文链接: https://www.lsjlt.com/news/183932.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0