【发布时间】:2016-12-28 10:41:18
【问题描述】:
所以我尝试使用用户选择的可变品牌。然后该变量将用于调用 Python 中的给定模块。目前在第 7 行,您可以看到“apple.solutions()”。但是,我本质上希望能够在“brand.solutions()”行上使用一些东西——尽管我知道这不起作用,因为它需要属性。我正在寻找一种解决方案来根据可变品牌选择模块。我将不胜感激任何解决方案或建议。谢谢,
主程序:
import apple, android, windows
brands = ["apple", "android", "windows"]
brand = None
def Main():
query = input("Enter your query: ").lower()
brand = selector(brands, query, "brand", "brands")
solutions = apple.solutions()
print(solutions)
Apple.py 模块文件(与主程序同目录):
def solutions():
solutions = ["screen", "battery", "speaker"]
return solutions
【问题讨论】:
标签: python arrays variables parameter-passing python-module