Advertisement
sanfx

write_index_file.py

Aug 17th, 2013
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. fobj = open(os.path.join(loc,index.text), “w+”)
  2. /* note: in the above line of code I have used os.path.join to build a path that contains the file name which is a better way of building the file path instead of overloading  “+” operator.*/
  3.  
  4. # saving the index to this index.txt file
  5.  
  6. for index, each in enumerate(files):
  7.     if index != 0:
  8.         fobj.write(str(index)+” ”+ each.split("-")[-1].split(".")[0]+”\n”)
  9.  
  10. # close the file
  11. fobj.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement