Python membuka file relatif terhadap lokasi skrip

import os

path = 'a/relative/file/path/to/this/script/file.txt'

with open(os.path.join(os.path.dirname(__file__), path), 'r') as input_file:
    content = input_file.read()
Arno Deceuninck