[英]how to solve AttributeError: module has no attribute python
I'm new to python, I have two python files in the same directory:我是 python 的新手,我在同一目录中有两个 python 文件:
file1文件 1
import file2
file2.print_x(x)
file2文件2
def print_x(x):
print(x)
I can't understand why I'm getting this error when I run file1.py我不明白为什么在运行 file1.py 时会出现此错误
AttributeError: module 'file2' has no attribute 'print'
you can do print(file2)
你可以
print(file2)
you can't do .print
write dir(file2)
to see all the available functions in file2您不能执行
.print
write dir(file2)
来查看 file2 中的所有可用函数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.