相关疑难解决方法(0)

__file__变量是什么意思/做什么?

A = os.path.join(os.path.dirname(__file__), '..')

B = os.path.dirname(os.path.realpath(__file__))

C = os.path.abspath(os.path.dirname(__file__))
Run Code Online (Sandbox Code Playgroud)

我通常只是用实际路径来硬连线.但是这些语句在运行时确定路径是有原因的,我真的很想了解os.path模块,所以我可以开始使用它.

python

140
推荐指数
6
解决办法
15万
查看次数

标签 统计

python ×1