Attribute Meaning  
__doc__ The function’s documentation string, or None if unavailable; not inherited by subclasses Writable
__name__ The function’s name Writable
__qualname__

The function’s qualified name

New in version 3.3.

Writable
__module__ The name of the module the function was defined in, or None if unavailable. Writable
__defaults__ A tuple containing default argument values for those arguments that have defaults, or None if no arguments have a default value Writable
__code__ The code object representing the compiled function body. Writable
__globals__ A reference to the dictionary that holds the function’s global variables — the global namespace of the module in which the function was defined. Read-only
__dict__ The namespace supporting arbitrary function attributes. Writable
__closure__ None or a tuple of cells that contain bindings for the function’s free variables. Read-only
__annotations__ A dict containing annotations of parameters. The keys of the dict are the parameter names, and 'return' for the return annotation, if provided. Writable
__kwdefaults__ A dict containing defaults for keyword-only parameters. Writable

获取当前的代码所在的文件名

__globals__['__file__']
D:\MARK\NOTE\temp.py

转载于:https://www.cnblogs.com/wancy86/p/6243725.html

python __globals__, __file__相关推荐

  1. python __file__ 与相对路径

    用__file__ 来获得脚本所在的路径是比较方便的,但这可能得到的是一个相对路径,比如在脚本test.py中写入: #!/usr/bin/env python print __file__ 按相对路 ...

  2. python 获取脚本所在目录

    pythonsys.path__file__abspathrealpath  平时写python经常会想获得脚本所在的目录,例如有个文件跟脚本文件放在一个相对的目录位置,那就可以通过脚本文件的目录找到 ...

  3. 从Python调用外部命令

    您如何在Python脚本中调用外部命令(就像我在Unix Shell或Windows命令提示符下键入的一样)? #1楼 os.system不允许您存储结果,因此,如果您要将结果存储在某个列表中或sub ...

  4. python3中 os.path.realpath(__file__) 的使用

    os.path.realpath 获取当前执行脚本的绝对路径. os.path.realpath(__file__) realpath() 获得的是该方法所在的脚本的路径 os.path.dirnam ...

  5. python编程01 -- 基础知识

    简介 本文主要对运用的python语言知识进行归纳和回顾使用,不定期更新,主要是对语言特性.数据类型.语句块.函数.类.模块.错误.线程.进程等内容的积累 python2/python3 核心类差异 ...

  6. Python模拟登陆淘宝并统计淘宝消费情况的代码实例分享

    支付宝十年账单上的数字有点吓人,但它统计的项目太多,只是想看看到底单纯在淘宝上支出了多少,于是写了段脚本,统计任意时间段淘宝订单的消费情况,看那结果其实在淘宝上我还是相当节约的说. 脚本的主要工作是模 ...

  7. Django模板系统(非常详细)

    翻译www.djangobook.com之第四章:Django模板系统 The Django Book:第4章 Django模板系统 revised by xin_wang 前面的章节我们看到如何在视 ...

  8. pygame图片精灵

    转向图片精灵 彩色矩形很好 - 它们是一个好的开始,并确保你的游戏基本工作,但迟早你会想要为你的精灵使用一个很酷的宇宙飞船图像或角色.这引出了第一个问题:在哪里获得游戏资源. 获取图片资源 当你需要为 ...

  9. 翻译www.djangobook.com之第四章:Django模板系统

    [color=red][b]The Django Book:第4章 Django模板系统[/b][/color] revised by [url=http://xin-wang.iteye.com/] ...

最新文章

  1. 【组队学习】【25期】Datawhale组队学习内容介绍
  2. ID3、C4.5、C5.0、CART决策树区别
  3. 程序员35岁生死大关!被迫无奈转行.....
  4. 2019_BUAAOO_第一单元总结
  5. linux 英伟达 分辨率,配置nVidia显卡修改Ubuntu分辨率
  6. 大众点评app 数据解密和反序列化
  7. Javascript函数调用的四种模式
  8. lc滤波电路电感电容值选择_滤波电容如何选择
  9. 动态规划优化_斜率优化
  10. Spring Boot 执行流程
  11. 工作几年只会增删改查怎么了,大神们都是从第一行代码开始的!
  12. 手动连接mysql_手动实现与数据库的连接
  13. java 错误代码2503_错误代码:11300001 数据集配置错误
  14. vmplayer7安装OSX10.10
  15. java 图片处理 图片缩略图_java 生成图片缩略图
  16. Python Package 之 Faker(随机姓名、电话)
  17. java将数字转换成大写_Java中金额数字转换为大写数字
  18. Unity导出视频/截图
  19. 工具教程第三十一讲:电报的使用(二)
  20. 什么是OpenID?OpenID概念、原理和案例

热门文章

  1. 【前端 · 面试 】HTTP 总结(二)—— HTTP 消息
  2. Android开发之动态加载,运行未安装apk
  3. 整理一下Entity Framework的查询
  4. docker安装带管理界面的rabbitmq
  5. ubunto应用软件
  6. PyQt5学习--基本窗口控件--加载文件-QFileDialog
  7. php判断搜索引擎来路,php实现判断访问来路是否为搜索引擎机器人的方法
  8. 2020-11-02 联想 Yoga Duet IML 2020
  9. GIS制图课程目录(持续整理)
  10. 企业级及电子商务常见缩写