i have .txt document called new_data.txt. data in document separated dots. want open file inside python, split , put inside list.
output = open('new_data.txt', 'a') output_list = output.strip().split('.') but have error:
attributeerror: 'file' object has no attribute 'strip' how can fix this?
note: program on python 2
first, want open file in read mode (you have in append mode)
then want read() file:
output = open('new_data.txt', 'r') # see r output_list = output.read().strip().split('.') this whole content of file.
currently working file object (hence error).
Comments
Post a Comment