您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python的__file__实际上做了什么?

5b51 2022/1/14 8:20:27 python 字数 1711 阅读 462 来源 www.jb51.cc/python

参见英文答案 > Is module __file__ attribute absolute or relative?????????????????????????????????????4个 我一直认为__file__变量总是给你当前的文件名,但这似乎并不完全是它的作用.因为如果我认为这是真的,我一直面临着一个错误. 有人告诉我“__file__指的是最后搜索的模块” 这似乎更准确,但我想知道

概述

有人告诉我“__file__指的是最后搜索的模块”
这似乎更准确,但我想知道__file__应该做什么.

我找不到Python文档中提到的任何具体内容.
很多地方似乎都提到它,但不是很清楚.

http://docs.python.org/2/c-api/import.html?highlight=__file__

http://docs.python.org/2/c-api/module.html?highlight=__file__

__file__ is the pathname of the file from which the module was loaded,if it was loaded from a file. The __file__ attribute is not present
 for C modules that are statically linked into the interpreter; for
 extension modules loaded dynamically from a shared library,it is the
 pathname of the shared library file.

从这里:
http://mail.python.org/pipermail/python-dev/2010-February/097461.html

总结

以上是编程之家为你收集整理的Python的__file__实际上做了什么?全部内容,希望文章能够帮你解决Python的__file__实际上做了什么?所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶