python __name__=='__main__' 使用法
script 1:
#!/bin/python
# Filename:name.py
if __name__=='__main__':
print 'This program is being run by itself'
else:
print 'I am being imported from another module'
script 2:
#!/bin/python
# filename:test.py
import name;
test.py
C:\Python27\python.exe C:/Users/Administrator/PycharmProjects/11/test.py
I am being imported from another module
Process finished with exit code 0
結論: