0
I’ve got it down:
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 treat this relative path to access the file?
What was the problem? He did not locate the file? What was the final value of
filename
?– Woss
It was something like "/home/Brito/projetos/este_projeto/me/~/Documents/projeto/me.py"
– britodfbr
See if this helps you: https://answall.com/a/335516/5878
– Woss