I'm trying to make a python based proof of concept system, and it has a "runcode" command,
I need to import code put into the file to run it, but dynamically, and with an alias
what I need:
import program-name as program
but a version for dynamics like this
__import__(program-name-variable)
but
__import__(program-name-variable) as program
doesn't work
someone found out the obvious answer I somehow missed, it was
program = import (...)
assign the variable with the needed name that you would normally put after "as"
program = __import__(program-name-variable)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.