Python学习篇 之 error
来源:互联网 发布:开淘宝店怎么找厂家 编辑:程序博客网 时间:2024/05/20 22:01
1 No moduled named ...
使用Pycharm ,在一个模块中导入另一个模块的时,出现“No module named ...”的错误
解决方法:找到目标文件所在的文件夹,将其标记为source root
2 TypeError: 'module' object is not callable
有Person.py模块如下:
class Person: def __init__(self,name='未知',sex='未知',age='未知'): self.name = name; self.sex = sex; self.age = age; def introduceMyself(self): print('My name is ',self.name,". I'm ",self.age,'years old now.')
在Test.py模块中使用Person模块中的Person类:
import Personperson = Person("MrZhang","男",22)person.introduceMyself();
出现错误:
TypeError: 'module' object is not callable
原因:
Python导入模块的方法有两种,import module和from module import*,区别是前者导入的东西使用时需要加上模块名进行限定,而后者不需要,直接使用即可。
import Personperson = Person.Person("MrZhang","男",22)person.introduceMyself();
或
from Person import*person = Person("MrZhang","男",22)person.introduceMyself();
阅读全文
0 0
- Python学习篇 之 error
- 步步学习Python 编程error篇:import package error:Import error: No module named mayavi
- python学习之基础篇
- Python学习之开头篇
- Python学习之环境篇
- Python学习之跨越篇
- Python学习之Strings篇
- Python学习之NumPy篇
- PYTHON学习之初识PYTHON
- Python学习之python 注释
- Error汇总之Android学习篇(持续更新)
- python学习之基础篇二
- python 学习之二 函数篇
- 01.python学习教程之表达式篇
- Python的学习之旅---开始篇
- Python学习第二篇之tuple
- Python学习之not,and,or篇
- Python学习之IPython/IPython notebook篇
- ubuntu14.04安装anaconda2.4.4.0 cuda8.0 cudnn5.1 tensorflow
- Atomic类和CAS
- MapReduce 例子:WordCount
- 图像的傅里叶变换,二维傅里叶变换的物理意义
- ios中一些常用的方法
- Python学习篇 之 error
- 欢迎使用CSDN-markdown编辑器
- 整数集合
- 红安学习实践有感
- 一个文科女的计算机菜鸟的进阶之路——第一天
- 404
- android studio环境配置视频教程
- 重构树 Fiolki
- 错排两大公式