python3 杂记

python3 杂记

test001

--test001.py       (

from test2.test002 import *

def test1():
print('1')

if __name__=='__main__':
test1()

test002

--test002.py       (

def test2():
print('2')
if __name__ == '__main__':
test2()

test003

--test003.py       (

from test1.test001 import *

def test3():
print('3')


if __name__=='__main__':
test3()
test2()
test1()

最后执行 test003.py输出 :

3
2
1

为什么test003.py没有导入test002,怎么会打印出2呢,因为在test001.py引入test002.py

原文地址:https://www.cnblogs.com/lystbc/p/7718208.html