# -*- coding: utf-8 -*- #python 27 #xiaodeng #Python学习手册 636 #用名称字符串导入模块(仅作了解即可) #默认情况下,exec运行当前作用域中的代码。 #案例 modname='test' result='import ' + modname exec(result) #运行字符串 print test #<module 'test' from 'C:\Users\Administrator\Desktop\test.pyc'> print test.name #python