diretório de arquivos python
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
Agreeable Ape
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
from os import path
dir_path = path.dirname(__file__)
path = 'C:\\Users\\Username\\Path\\To\\File'
file=open(path, "r")
import os
print('File name : ', os.path.basename(__file__))
print('Directory Name: ', os.path.dirname(__file__))