在同一个解决方案中,我有导入 SQL 的项目和我的游戏项目。 不幸的是,当我输入“from highscore import *”时,它无法在游戏文件中识别它。 我错过了一些重要的事情吗?
最佳答案
使用import *
被认为是不好的做法。
您最好使用 from highscore import Score
或 import 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/