📜  __file__ python 代码示例

📅  最后修改于: 2022-03-11 14:46:16.686000             🧑  作者: Mango

代码示例1
A = os.path.join(os.path.dirname(__file__), '..')
# A is the parent directory of the directory where program resides.

B = os.path.dirname(os.path.realpath(__file__))
# B is the canonicalised (?) directory where the program resides.

C = os.path.abspath(os.path.dirname(__file__))
# C is the absolute path of the directory where the program resides.