×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: Matthew J_
Added: Jun 22, 2022 11:27 PM
Modified: Jun 22, 2022 11:59 PM
Views: 0
Tags: no tags
  1. #The following one liner reads a txt file
  2. # and adds each line as a new element in a list.
  3.  
  4.  
  5. lst = [line.strip() for line in open('requirements.txt', 'r')]
  6.  
  7. print(lst)  # ['pandas']