从同一文件夹导入Python软件包时,如何修复函数的重叠?

发布于 2025-01-25 00:44:13 字数 452 浏览 1 评论 0原文

我有一个称为libs的文件夹,它有两个文件(database.pykeymanagementservice.py)在Libs文件夹外部文件。为此,我在Libs文件夹中做了一个__ INIT

from Libs.database import *
from Libs.keyManagmentService import *

import Libs as db 
import Libs as kms

__ 数据库文件与KeyManagementservice文件的函数重叠,因此,如果我尝试使用db例如,kms的函数也将显示。如何使这些图书馆独立,因为缺乏更好的措辞?谢谢!

I have a folder called Libs that has two files (database.py and keyManagementService.py) I'd like to import as libraries to another file outside of the Libs folder. To do that, I made an __init__.py in the Libs folder which looks like this:

from Libs.database import *
from Libs.keyManagmentService import *

The way I imported the libraries to a file outside of Libs was like this:

import Libs as db 
import Libs as kms

However, the issue is the functions from the database file overlaps with the functions from the KeyManagementService file, so if I try using db for example, the functions from kms would also show up. How can I make these libraries standalone for a lack of better wording? Thanks!

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

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

发布评论

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

评论(1

婴鹅 2025-02-01 00:44:13

如果您从__ Init __.py中清除内容(但请留空文件),您应该能够

from Libs.database import the_exact_names_you_need
from Libs.keyManagementService import the_names_you_need_from_this_file

If you clear the content from __init__.py (but leave the empty file), you should be able to

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