【发布时间】:2014-02-13 09:53:02
【问题描述】:
我创建了一个模块 modA,并将其导入到我的主程序中。根据我的主程序中发生的情况(它具有交互模式和批处理脚本模式),我希望 modA 本身使用 TkAgg 后端或 ps 后端导入 matplotlib。有没有办法让我的主程序向 modA 传达信息,告诉它应该如何导入 matplotlib?
澄清情况:
主程序:
#if we are in interactive mode
#import modA which imports matplotlib using TkAgg backend
#else
#import modA which imports matplotlib using the ps backend
模块 modA:
#import matplotlib
#matplotlib.use('ps') or matplotlib.use('TkAgg') (how can I do this?)
【问题讨论】:
-
是否可以以 2 个不同的名称两次导入像 matplotlib 这样的模块,即。将 matplotlib 导入为 matplotlib1 并将 matplotlib 导入为 matplotlib2,然后根据我的需要使用其中一个或另一个?
标签: python matplotlib