I have the method below:
def get_conteudo_file(filename: str, encoding: str="iso8859-1") -> str:
filename = os.path.abspath(os.path.join(*filename.split(os.sep)))
assert os.path.isfile(filename), "Arquivo '{}' indisponível".format(filename)
with open(filename, encoding=encoding) as f:
logging.debug('filename: "{}" readed'.format(f.name))
return f.read()
get_conteudo_file("~/Documents/projeto/me.py", "utf-8")
How to handle this relative path to access the file?