Python使用 'from ... import *'链接相同解决方案中的两个项目

标签 python import

在同一个解决方案中,我有导入 SQL 的项目和我的游戏项目。 不幸的是,当我输入“from highscore import *”时,它无法在游戏文件中识别它。 我错过了一些重要的事情吗?

最佳答案

使用import *被认为是不好的做法。 您最好使用 from highscore import Scoreimport highscore 仅导入所需的内容。

What are the “best practices” for using import in a module?

In general, don’t use from modulename import *. Doing so clutters the importer’s namespace, and makes it much harder for linters to detect undefined names.

关于Python使用 'from ... import *'链接相同解决方案中的两个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41933912/

相关文章:

python - 导入 __module__ python : why the underscores?

python - 256GB RAM、64 位 python 和 64 位 numpy 的 Numpy 内存错误。限制问题?

python - 通过 Google Drive API 访问共享云端硬盘时出现 404 错误

MySQL phpMyAdmin 从文本导入没有主键?

xml - 将包含多个工作表的 Excel 2003 xml 文件导入 Microsoft Dynamics 2011

python 包——覆盖内置包和可怕的 "Module xxxx was already imported"警告

python - sklearn standardscaler 结果与手动结果不同

python - 如何获取 boolean numpy 数组和另一个 boolean 数组的相对补集?

python - tensorflow 错误: how to make tensor A the same graph as Tensor B

sql - sql如何将一张表的数据导入到另一张表