-1
I wrote this script to check if the texts are the same, if you do not add the texts you do not have in the other file, but I am receiving this error syntax and I do not understand the reason, is it a logic error? Follows the script: Error: File "write.py", line 3 with open('testee.txt', 'r') as fileOld; ^ Syntaxerror: invalid syntax
try:
with open('testee.txt', 'r') as fileOld;
with open('teste.txt', 'r') as fileNew;
addFile = fileOld.readlines();
accFile = fileNew.readlines();
except IOError:
print("Erro na leitura dos arquivos", IOError);
key = "public virtual";
keyStop = "using";
stop = false;
for addlinha in addFile:
if key in addlinha:
for acclinha in accFile:
if key in accFile:
if not addlinha in acclinha:
try:
acclinha.write(addlinha);
except IOError:
print("Houve erros na gravação", IOError);
else:
if keyStop in addlinha:
stop = true;
Are you using the
with
completely wrong, it defines a context manager and, to use it correctly, you need to use the context it generates. Read this question: What’s with no Python for?– Woss
I used the open in the traditional way, yet the error persists. But vlw I will read the article.
– Julio Vilela