简体   繁体   English

如何解决 AttributeError: module has no attribute python

[英]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.

相关问题 如何解决名为AttributeError的python程序中的错误:'module'对象没有属性'TensorFlowLinearClassifier' - How to solve error in python program named: AttributeError: 'module' object has no attribute 'TensorFlowLinearClassifier' 如何解决Python抓取错误:AttributeError:'模块'对象没有属性'对象' - How to solve Python praw error : AttributeError: 'module' object has no attribute 'objects' 如何解决此 Python AttributeError: module 'matplotlib' has no attribute 'get_data_path' (在 JupyterLab 3.0>= 中) - How to solve this Python AttributeError: module 'matplotlib' has no attribute 'get_data_path' (in JupyterLab 3.0>=) 如何解决“AttributeError: module 'xmltodict' has no attribute 'parse'”。? - How to solve the "AttributeError: module 'xmltodict' has no attribute 'parse'".? 如何解决 AttributeError: module 'numpy' has no attribute 'bool'? - How to solve AttributeError: module 'numpy' has no attribute 'bool'? 如何解决错误:AttributeError: module 'pyglfw' has no attribute 'pyglfwInit' - How to solve the error : AttributeError: module 'pyglfw' has no attribute 'pyglfwInit' AttributeError:模块'scipy.misc'没有属性'imread',如何解决? - AttributeError: module 'scipy.misc' has no attribute 'imread', How to solve it? 如何解决AttributeError:'module'对象在opencv中没有属性'createBackgroundSubtractorMOG'? - How to solve AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG' in opencv? 如何解决 AttributeError: module 'keras.optimizers' has no attribute 'Adam' - how to solve AttributeError: module 'keras.optimizers' has no attribute 'Adam' 如何解决 AttributeError:模块 'serial' 在 pyserial 中没有属性 'Serial'? - How to solve AttributeError: module 'serial' has no attribute 'Serial' in pyserial?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM