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经常会想获得脚本所在的目录,例如有个文件跟脚本文件放在一个相对的目录位置,那就可以通过脚本文件的目录找到对应的文件,即使以后脚本文件移到其他地方,脚本也基本不需要改动(相对于写死目录 ...
随机推荐
- 论:开发者信仰之“天下IT是一家“(Java .NET篇)
比尔盖茨公认的IT界领军人物,打造了辉煌一时的PC时代. 2008年,史蒂夫鲍尔默接替了盖茨的工作,成为微软公司的总裁. 2013年他与微软做了最后的道别. 2013年以后,我才真正看到了微软的变化. ...
- 拨开迷雾,找回自我:DDD 应对具体业务场景,Domain Model 到底如何设计?
写在前面 除了博文内容之外,和 netfocus 兄的讨论,也可以让你学到很多(至少我是这样),不要错过哦. 阅读目录: 迷雾森林 找回自我 开源地址 后记 毫无疑问,领域驱动设计的核心是领域模型,领 ...
- 8、Struts2 运行流程分析
1.流程分析: 请求发送给 StrutsPrepareAndExecuteFilter StrutsPrepareAndExecuteFilter 询问 ActionMapper: 该请求是否是一个 ...
- RabbitMq应用一
RabbitMq应用一 RabbitMQ的具体概念,百度百科一下,我这里说一下我的理解,如果有少或者不对的地方,欢迎纠正和补充. 一个项目架构,小的时候,一般都是传统的单一网站系统,或者项目,三层架构 ...
- dotNet Core开发环境搭建及简要说明
一.安装 .NET Core SDK 在 Windows 上使用 .NET Core 的最佳途径:使用Visual Studio. 免费下载地址: Visual Studio Community 20 ...
- C#泛型详解(转)
初步理解泛型: http://www.cnblogs.com/wilber2013/p/4291435.html 泛型中的类型约束和类型推断 http://www.cnblogs.com/wilber ...
- SSH框架和Redis的整合(2)
5. 添加功能的实现 新建一个Action:RClasAction,实现向Redis添加课程数据,并同步到MySQL. package com.school.action; import java.u ...
- JDBC MySQL 多表关联查询查询
public static void main(String[] args) throws Exception{ Class.forName("com.mysql.jdbc.Driver&q ...
- JavaScript求两个数字之间所有数字的和
这是在fcc上的中级算法中的第一题,拉出来的原因并不是因为有什么好说的,而是我刚看时以为是求两个数字的和, 很显然错了.我感觉自己的文字理解能力被严重鄙视了- -.故拉出来折腾折腾. 要求: 给你一个 ...
- Node.js入门(一)
一.Node.js本质上是js的运行环境. 二.可以解析js代码(没有浏览器安全级的限制): 提供系统级的API:1.文件的读写 2.进程的管理 3.网络通信 三.可以关注的四个网站: 1.https ...