我在阅读有关 python 中的导入的内容时遇到了这个 effbot article关于进口。
Python provides at least three different ways to import modules. You can use the
import
statement, thefrom
statement, or the builtin__import__
function. (There are more contrived ways to do this too, but that’s outside the scope for this small note.)
我想知道是否有人能够指出一些或所有可以做到这一点的人为方法?我能想到的实现导入的唯一其他方法是
exec("import os")
以及在 exec
语句中创建字符串的所有可能的人为方法。
最佳答案
这是否足够人为设计?
os = getattr(__builtins__, "".join(chr(ord(x) - 1) for x in "``jnqpsu``"))("os")
关于python - python导入,有多少种方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10444358/