[Python] multiple import

#a.py
print("in a.py berfore import b")
import b
print("in a.py after import b")
#b.py
print ("in b.py")
#c.py
print("in c.py berfore import b")
import b
print("in c.py after import b")
#d.py
print("in d.py berfore import a")
import a
print("in d.py after import a")

print("in d.py berfore import c")
import c
print("in d.py after import c")
in d.py berfore import a
in a.py berfore import b
in b.py
in a.py after import b
in d.py after import a
in d.py berfore import c
in c.py berfore import b
in c.py after import b
in d.py after import c
>>> a.b.x = 1
>>> c.b.x
1
>>> a.b

>>> c.b

>>> 

重複import會被視為同一個物件

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *