0

I need to import files in a loop, each file has a different name, say 'file_{}.py'.format(i) where i is an iterated index. How can I do that?

  • Does this answer your question? [How to import a module given its name as string?](https://stackoverflow.com/questions/301134/how-to-import-a-module-given-its-name-as-string) – Gorisanson Jul 23 '20 at 11:43
  • I tried importlib.import_module, i get the error "ModuleNotFoundError: No module named 'file_0.py'; 'file_0' is not a package". Maybe I should have clarify befor: The files I want to import are python files and not recognized modules – Jonny Jul 23 '20 at 15:07

0 Answers0