我還沒有達到我擁有工具(或知道如何開發或使用它們)的水平來測試和分析看似簡單的事情,比如我的問題,所以我轉向你。將模塊導入循環函數中導入?
我有一個函數,檢查一個條件,並根據該條件挑選最佳數學工具(不同的模塊),但該函數應用於數組的窗口,因此是循環的。從窗口到窗口可能會出現不同的導入,但這導致我懷疑導入是否實際上是循環的,並且這完全是性能問題。
下面是從matplotlib源
def pause(interval):
"""
Pause for *interval* seconds.
If there is an active figure it will be updated and displayed,
and the GUI event loop will run during the pause.
If there is no active figure, or if a non-interactive backend
is in use, this executes time.sleep(interval).
This can be used for crude animation. For more complex
animation, see :mod:`matplotlib.animation`.
This function is experimental; its behavior may be changed
or extended in a future release.
"""
backend = rcParams['backend']
if backend in _interactive_bk:
figManager = _pylab_helpers.Gcf.get_active()
if figManager is not None:
canvas = figManager.canvas
canvas.draw()
show(block=False)
canvas.start_event_loop(interval)
return
# No on-screen figure is active, so sleep() is all we need.
import time
time.sleep(interval)
如果我在一個循環中交替打開和關閉數字將時間被導入每隔一個循環的例子?或者剛剛導入第一次導入時被調用並忽略後續導入?
感謝
這一定是一個愚蠢的問題,我被captcha篩選了兩次,第一次輸入了錯誤的一個T_T – arynaq