Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python read line into list

with open("data_file.txt") as f:
    content_list = f.readlines()

# print the list
print(content_list)

# remove new line characters
content_list = [x.strip() for x in content_list]
print(content_list)
Comment

PREVIOUS NEXT
Code Example
Python :: python multithreading tutorials 
Python :: how to run django tests 
Python :: how to generate random normal number in python 
Python :: python list abstraction 
Python :: len of int python 
Python :: python one line if else 
Python :: all the positions of a letter occurrences in a string python 
Python :: how to use sum with range python 
Python :: public in python 
Python :: save dictionary to file numpy 
Python :: merge two df 
Python :: python string to array 
Python :: dataframe change column value 
Python :: how to execute python program in ubuntu 
Python :: stdout.write python 
Python :: multirow np.rand.randint 
Python :: pdf to text python 
Python :: random.shuffle 
Python :: how to close a webpage using selenium driver python 
Python :: python program to add two numbers 
Python :: how to set default user group in django 
Python :: pyautogui color 
Python :: Math Module sqrt() Function in python 
Python :: numpy flatten 
Python :: button size tkinter 
Python :: spacy nlp load 
Python :: python set intersection 
Python :: isidentifier method in python 
Python :: concatenate dataframes 
Python :: capitalise words in a column pandas 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =