如何在 python 应用程序中使用 Visual Studio 2017 年的用户包

How to use user packages in Visual Studio 2017 in a python application

我在 Visual Studio 2017 年有这个 python 应用程序结构。 我使用解决方案资源管理器创建了一个 tests 文件夹,其中有一个 test.py 文件。 我想使用存储在 tests 目录中的 test 模块。 但是当我尝试使用 import tests.test 时,它说 test 未定义。 我刚开始学习python。 我仰望 this but I dont understand why isnt it working. Am I doing something wrong? I looked it up here

您正在尝试从包中导入。每个 package 必须有一个 __init__.py 文件。您只需添加一个空白文件 __init__.py 到您的 tests 文件夹,然后就可以了。