Python 模块中的一些全局变量

mac2022-06-30  21

__name__ 如果是主文件__name__=='__main__' 否则等于模块名 __file__ 当前文件路径 __package__ 当前文件所在包,用 . 分割 __doc__ py文件的注释 __cached__ 缓存 __loader__ __builtins__ __spec__

 

给import sys,os path=os.path.dirname(__file__) file='bin' fp=os.path.join(path,file) sys.path.append(fp)

 

转载于:https://www.cnblogs.com/ezway/p/6514816.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)