Unable to write output from os.path.walk to a file.

Discussion in 'Python' started by Paul Lemelle, Jun 4, 2008.

  1. Paul Lemelle

    Paul Lemelle Guest

    I Am trying to output the os.path.walk to a file, but the writelines method complains....

    Below is the code, any helpful suggestions would be appreciated.

    def visit(arg, dirnames, names):
    print dirnames




    dirinput = raw_input("Enter directory to read: ")

    listdir = os.path.walk (dirinput, visit, None)

    f = open("walktxt", "w")

    f.writelines(listdir)

    f.close()
     
    Paul Lemelle, Jun 4, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joel Finkel
    Replies:
    1
    Views:
    3,576
    Joel Finkel
    Aug 15, 2003
  2. Gary
    Replies:
    0
    Views:
    862
  3. Replies:
    1
    Views:
    1,827
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    May 13, 2005
  4. Marcus Alves Grando
    Replies:
    7
    Views:
    494
    Marcus Alves Grando
    Nov 14, 2007
  5. dude
    Replies:
    5
    Views:
    1,783
    Jussi Piitulainen
    Mar 17, 2011
Loading...

Share This Page