import() 函式

__import__() 函式可用於匯入名稱僅在執行時已知的模組

if user_input == "os":
    os = __import__("os")

# equivalent to import os

此函式還可用於指定模組的檔案路徑

mod = __import__(r"C:/path/to/file/anywhere/on/computer/module.py")