python __globals__, __file__
| Attribute | Meaning | |
|---|---|---|
__doc__ |
The function’s documentationstring, or None ifunavailable; not inherited bysubclasses |
Writable |
__name__ |
The function’s name | Writable |
__qualname__ |
The function’squalified name New in version 3.3. |
Writable |
__module__ |
The name of the module thefunction was defined in, orNone if unavailable. |
Writable |
__defaults__ |
A tuple containing defaultargument values for thosearguments that have defaults,or None if no argumentshave a default value |
Writable |
__code__ |
The code object representingthe compiled function body. | Writable |
__globals__ |
A reference to the dictionarythat holds the function’sglobal variables — theglobal namespace of themodule in which the functionwas defined. | Read-only |
__dict__ |
The namespace supportingarbitrary functionattributes. | Writable |
__closure__ |
None or a tuple of cellsthat contain bindings for thefunction’s free variables. |
Read-only |
__annotations__ |
A dict containing annotationsof parameters. The keys ofthe dict are the parameternames, and 'return' forthe return annotation, ifprovided. |
Writable |
__kwdefaults__ |
A dict containing defaultsfor keyword-only parameters. | Writable |
获取当前的代码所在的文件名
__globals__['__file__']
D:\MARK\NOTE\temp.py
python __globals__, __file__的更多相关文章
- python中__file__
用__file__ 来获得脚本所在的路径,比如文件在/root下 cat tee #!/usr/bin/env pythonprint __file__ #得到相对路径tee ...
- python的__file__和__name__变量
#现在的目录结构为 #现在想要在web2/bin.py中调用web3/main.py模块中的方法 from web3 import main main.foo() #在pycharm中执行 ##### ...
- python 的__FILE__,__LINE__功能实现
在C语言里,__FILE__和__LINE__给调试提供了很大的方便,今晚在写PYTHON的时候想到,PYTHON是否有类似的功能实现呢? GOOGLE一番发现两个方法,试验一下下面这句:print ...
- python中 __file__的小坑坑
在python脚本中,我们难免会需要用到自身文件所在的绝对路径,第一想法可能就是用os.path.dirname(__file__) 但是这里有个大坑,我就踩了,这种方式得到路径会出现问题,脚本执行报 ...
- python __file__ 与相对路径
用__file__ 来获得脚本所在的路径是比较方便的,但这可能得到的是一个相对路径,比如在脚本test.py中写入: #!/usr/bin/env pythonprint __file__ 按相对路径 ...
- python __file__ 与argv[0]
在python下,获取当前执行主脚本的方法有两个:sys.argv[0]和__file__. sys.argv[0] 获取主执行文件路径的最佳方法是用sys.argv[0],它可能是一个相对路径,所以 ...
- python解惑之 __file__ 与argv[0]
在python下,获取当前执行主脚本的方法有两个:sys.argv[0]和__file__. sys.argv[0] 获取主执行文件路径的最佳方法是用sys.argv[0],它可能是一个相对路径,所以 ...
- [py]python __file__ 与argv[0]
http://andylin02.iteye.com/blog/933237 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__ ...
- python 获取脚本所在目录
平时写python经常会想获得脚本所在的目录,例如有个文件跟脚本文件放在一个相对的目录位置,那就可以通过脚本文件的目录找到对应的文件,即使以后脚本文件移到其他地方,脚本也基本不需要改动(相对于写死目录 ...
随机推荐
- Tomcat一个BUG造成CLOSE_WAIT
之前应该提过,我们线上架构整体重新架设了,应用层面使用的是Spring Boot,前段日子因为一些第三方的原因,略有些匆忙的提前开始线上的内测了.然后运维发现了个问题,服务器的HTTPS端口有大量的C ...
- Scrapy框架爬虫初探——中关村在线手机参数数据爬取
关于Scrapy如何安装部署的文章已经相当多了,但是网上实战的例子还不是很多,近来正好在学习该爬虫框架,就简单写了个Spider Demo来实践.作为硬件数码控,我选择了经常光顾的中关村在线的手机页面 ...
- android 使用Tabhost 发生could not create tab content because could not find view with id 错误
使用Tabhost的时候经常报:could not create tab content because could not find view with id 错误. 总结一下发生错误的原因,一般的 ...
- jquery.cookie的使用
今天想到了要为自己的影像日记增加赞的功能,并且需要用到cookie. 记得原生的js操作cookie也不是很麻烦的,但似乎jquery更简单,不过相比原生js,需要额外引入2个文件,似乎又不是很好,但 ...
- java springMVC SSM 操作日志 4级别联动 文件管理 头像编辑 shiro redis
A 调用摄像头拍照,自定义裁剪编辑头像 B 集成代码生成器 [正反双向](单表.主表.明细表.树形表,开发利器)+快速构建表单; 技术:313596790freemaker模版技术 ,0个代码不用写 ...
- 敏捷测试模式之Scrum及其实践
一. 敏捷开发模式简介 敏捷是近年来软件研发领域很火的一个词,采用敏捷开发模式的研发团队是越来越多了,尤其是敏捷模式中的Scrum更是佼佼者大行其道,这表明敏捷模式确有其好处,能给企业带来效率的 ...
- PADS Layout 颜色设置
一.板框.装配线.标注线配置: 二.个人爱好,我一般把Top pads设置成为浅绿色,Top Trace/vias/2D Line/Text/Cooper设置成为深绿色,Error设置成为黄色,而Bo ...
- EF里Guid类型数据的自增长、时间戳和复杂类型的用法
通过前两章Lodging和Destination类的演示,大家肯定基本了解Code First是怎么玩的了,本章继续演示一些很实用的东西.文章的开头提示下:提供的demo为了后面演示效果,前面代码有些 ...
- Yeoman 学习笔记
yoeman 简介:http://www.infoq.com/cn/news/2012/09/yeoman yeoman 官网: http://yeoman.io/ yeoman 是快速创建骨架应用程 ...
- 认识ASP.NET 5项目结构和项目文件xproj
ASP.NET 5 在项目结构上做了很大的改变,我们以前熟悉的目录结构与项目文件内容都不太一样了,本篇文章带大家了解 ASP.NET 5 到底跟以前有哪些不一样的地方. 我们先用 Visual Stu ...