Например:
Код: Выделить всё
workspace
--|main.py
----|subfolder1
------|subfolder2
--------|file1.py
--------|file2.py
Я пытаюсь использовать библиотеку importlib > модуль для динамического импорта.
Код: Выделить всё
# main.py
file = input("Either file1 or file2")
try:
mod = importlib.import_module(f"subfolder1.subfolder2.{file}")
except Exception as error:
print(f"[ERROR] {error}!")
else:
mod.run()
Подробнее здесь: https://stackoverflow.com/questions/792 ... bdirectory
Мобильная версия