I\'m facing an error as:
UnboundLocalError: local variable \'fullfilename\' referenced before assignment
Code block:
caminho_pa
This error message...
UnboundLocalError: local variable 'fullfilename' referenced before assignment
...implies that you have referenced the variable fullfilename
even before it was assigned any value.
In your code block:
for arquivo in arquivos:
if arquivo.endswith(".zip"):
fullfilename = os.path.join(caminho_path, arquivo)
the variable fullfilename
is assigned a value only when the condition arquivo.endswith(".zip")
is true
. Else the variable fullfilename
remains unassigned.
In one of such cases when the variable was left unassigned, you have tried to reference it at a later part in your code as:
with ZipFile(fullfilename, 'r') as zipObj:
Even when the variable fullfilename
was still unassigned. Hence you see the error.