Here is what I have been trying to use:
filename = str(input("Enter a file name: "))
file = filename.split('.')
file = file[0]
from file import *
However, the interpreter doesn't attempt to look for the variable assigned to file, and looks for a module named 'file' does anyone have a solution to this?
I think that this might work for you:
import importlib
module = importlib.import_module(filename.split('.')[0])
Then you should be able to use module in order to call any of the imported functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With