Python Can';t将日志记录模块导入主文件

Python Can';t将日志记录模块导入主文件,python,import,Python,Import,我正在学习python,并尝试学习有关日志记录的课程,但我无法使用模块: 以下是我要导入的模块: helper.py import logging def helper(): logging.info('hello from helper') 以下是主文件: logs.py 下面是termianl所说的: Traceback (most recent call last): File "c:\Users\DoggoBeatz\vsc projects\logs.py&qu

我正在学习python,并尝试学习有关日志记录的课程,但我无法使用模块:

以下是我要导入的模块: helper.py

import logging
def helper():
    logging.info('hello from helper')
以下是主文件: logs.py

下面是termianl所说的:

Traceback (most recent call last):
  File "c:\Users\DoggoBeatz\vsc projects\logs.py", line 10, in <module>
    helper.helper()
AttributeError: module 'helper' has no attribute 'helper'
回溯(最近一次呼叫最后一次):
文件“c:\Users\DoggoBeatz\vsc projects\logs.py”,第10行,在
helper.helper()
AttributeError:模块“helper”没有属性“helper”

您没有在
日志中导入
帮助程序
。py
这与
日志记录
以及所有导入无关,所以为什么您没有导入
帮助程序
,也许它必须做到模块和函数的名称是相同的。请您将问题扩展到一个新的版本。如图所示的代码将失败,并出现
名称错误
。这是否回答了您的问题?我尝试更改模块和文件的名称,仍然是相同的错误
Traceback (most recent call last):
  File "c:\Users\DoggoBeatz\vsc projects\logs.py", line 10, in <module>
    helper.helper()
AttributeError: module 'helper' has no attribute 'helper'