为什么我的用户定义的模块未通过测试脚本找到?

发布于 2025-01-17 22:44:28 字数 435 浏览 1 评论 0原文

我尝试为我的项目创建用户定义的模块,但我的脚本正在失败。

modulenotfounderror:no模块名为“ config”

我项目的结构就是这样:

Project <Folder>
   |
   --- Config <Folder>
   |        |
   |        --- __init.py__
   |        --- Config.py
   --- Test cases
            |
            --- Testcase1.py

testcase1.py的内容是

import Config as config
print (config.main_url)

I tried creating the user-defined module for my project but my script is getting failed with an error message

ModuleNotFoundError: No module named 'Config'

The structure of my project is like this:

Project <Folder>
   |
   --- Config <Folder>
   |        |
   |        --- __init.py__
   |        --- Config.py
   --- Test cases
            |
            --- Testcase1.py

And the content of Testcase1.py is

import Config as config
print (config.main_url)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水染的天色ゝ 2025-01-24 22:44:28

您的用户定义模块应该位于同一目录中。

Your user-defined module should be in the same directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文