Read Text File Into Dictionary Removing Heading/trailing Newlines
This will be much easier to understand if I just show you the text file I'm working with and the code I have. Here's the text file, called employees.txt: 7 John Doe 33 272838 M Mar
Solution 1:
Whereever you read using readline()
, use readline().strip()
Solution 2:
.strip()
without an argument strips all spaces/tabs/newlines
Post a Comment for "Read Text File Into Dictionary Removing Heading/trailing Newlines"