I try to remove the '\n' after i get the data from my test file and i stile see a new lines in the output.
users_data = open('users.txt', 'r')
line = users_data.readline()
while line:
line.strip('\n')
metode, data = line.split(":")
d = {} #for debuging
d[metode]=data
print(d)
line = users_data.readline()
i put them in dictionary for debugging and i get :
{'gender': 'f\n'}
{'name': 'elise\n'}
Did i done something wrong?
Since strings are immutable line.strip() will not do anything at all. strip() is not an inplace operation, it will return a new string.
line = line.strip()
is what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With