简体   繁体   中英

Usage of importlib.import_module to replace from m import v

Does anyone know what is the equivalent of

from modulename import var

if I wanted to use import_module

importlib.import_module

The following works

_tmep = importlib.import_module(modulename)
var = _temp.var

Or in one line as:

var = importlib.import_module(modulename).var

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM