Python 的特殊变量 __name__
This commit is contained in:
parent
59f60078cb
commit
3daaced0ee
13
tests/VariableName/ImportVarName.py
Normal file
13
tests/VariableName/ImportVarName.py
Normal file
@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Python __name__ module ImportVarName
|
||||
# Author - HoneyMoose(huyuchengus@gmail.com)
|
||||
# Link Article - https://www.ossez.com/t/python-name/13393
|
||||
|
||||
|
||||
print("ImportVarName __name__ = %s" % __name__)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("ImportVarName is being run directly")
|
||||
else:
|
||||
print("ImportVarName is being imported")
|
14
tests/VariableName/VarName.py
Normal file
14
tests/VariableName/VarName.py
Normal file
@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Python __name__ module Test
|
||||
# Author - HoneyMoose(huyuchengus@gmail.com)
|
||||
# Link Article - https://www.ossez.com/t/python-name/13393
|
||||
|
||||
import ImportVarName
|
||||
|
||||
print("Main VarName __name__ = %s" % __name__)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("VarName is being run directly")
|
||||
else:
|
||||
print("VarName is being imported")
|
Loading…
x
Reference in New Issue
Block a user