python文件/模块都有一个内置属性file,属性的值是文件的位置,即绝对路径
例如:
import random
import os
#查看random模块的绝对路径
print(random.__file__)
#查看os模块是否有__file__属性:
[attr for attr in dir(os) if attr.startswith("__")]
#输出结果中有__file__属性
2023-05-13编程教程下载本文__FILE__,python,内
python文件/模块都有一个内置属性file,属性的值是文件的位置,即绝对路径
例如:
import random
import os
#查看random模块的绝对路径
print(random.__file__)
#查看os模块是否有__file__属性:
[attr for attr in dir(os) if attr.startswith("__")]
#输出结果中有__file__属性
《python的内置属性__file__.doc》
下载本文的Word格式文档,以方便收藏与打印。