i create a python file via the "with open()" method and now i would like to import the file but the filename should be variable.
filename = "Test"
with open(filename + ".py", "w+") as file:
file.write("def main():
pass")
Now at a other line in the skript i would like to import the python script called like filename. But you cant do something like:
import filename
because then python searches for a python script called "filename". but in this example it should import "Test.py". Any suggestions?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…