Python does not return files within a directory

1

Good night I'm new to Python programming but I created this code using os.listdr and did not return any results from the files inside the folder. If anyone has any idea how to solve thank you very much. follow the code:

import os

def rename_files():

#(1) Obter nomes de arquivos de uma pasta
file_list = os.listdr(r"C:\Users\Deivid\Pictures\Imagens\prank")
print (file_list)
    
asked by anonymous 27.07.2017 / 00:15

3 answers

1

Thank you for the help, but I solved the problem and I managed to run the script, here is the reshaped script:

import os
def rename_files():     
list_files = os.listdir(r"diretório")
print(list_files)
rename_files()

The problem is that the empty function was missing     def rename_files ():    rename_files ()

    
29.07.2017 / 02:32
0

By the way it's syntax error I ran the script here and it worked.

def rename_files():
...     file_list = os.listdir(r"diretorio")
...     print(file_list)
    
27.07.2017 / 00:36
0

Friend you forgot an 'i':

import os

def rename_files():

    #(1) Obter nomes de arquivos de uma pasta
    file_list = os.listdir(r"C:\Users\Goku\MaisdeOitoMil")
    print (file_list)

rename_files()
    
27.07.2017 / 06:55