![](/img/trans.png)
[英]Why I am receiving the error Error: module ‘string’ has no attribute ‘lower’ when I am using Pandas?
[英]Why Am I getting Module has no attribute error when adding "as"
我有一个目录module
,其中有一个 python 文件tools.py
我需要从module
的父目录导入tools.py
。
当我指定import module.tools
时,一切正常。
但是import module.tools as tools
不起作用。 我得到一个错误: Module module has no attribute tools
使用from module import tools
代替as
。 这将仅从module
导入tools
。
from module import tools
如果您想将工具重命名为更短的名称,您可以稍后在代码中执行此操作。
t = tools
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.