Results 1 to 2 of 2

Thread: Getting files in python with os.listdir

  1. #1
    Join Date
    May 2016
    Beans
    1

    Question Getting files in python with os.listdir

    Hello, I'm doing a course in Udacity and this simple code works good on the instructors video, he's using windows. I don't see why It doesn't work on ubuntu. I already made sure that that's the current link to the files.

    import os

    def rename_files():
    #(1) get files names from a given folder
    file_list = os.listdir("/home/jesus/Downloads/prank/prank")
    print(file_list)



    Thanks for the help!

  2. #2
    Join Date
    May 2014
    Beans
    138

    Re: Getting files in python with os.listdir

    Do you have indented third and fourth lines? This code here is not formated, so I am not sure. Generally it works.

    What errors do you have when you try to use this code?

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •