Advertisement
here2share

# void_io_newline_esc.py

May 6th, 2015
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. # void_io_newline_esc.py
  2.  
  3. # List_of_Values.txt file with the following in it --
  4. '''
  5. Value1
  6. Value2
  7. Value3
  8. Value4
  9. '''
  10.  
  11. # Code showing newline after each value...
  12. '''
  13. t = open('List_of_Values.txt', 'r+w')
  14. contents = t.readline()
  15.  
  16. mylist = []
  17.  
  18. for i in contents:
  19.    mylist.append(i)
  20. '''
  21.    
  22. # output >>> ['Value1\n', 'Value2\n', ...] but, considering the \n is not needed...
  23.  
  24. mylist = open(List_of_Values.txt).read().splitlines()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement