0

I have a .properties file where the environment details are written like this:-

DEVOPS_app=app1,app2
DEVOPS_bat=bat1,bat2

I want my code to read this file to search for a particular environment (For Ex - "DEVOPS" here) and save all the content after "=" in a list. Here for example list_app will contain app1 and app2 and list_bat will contact bat1 and bat2.

I am new to python so need someone's help here.

Thanks.

Md. Rezwanul Haque
  • 2,882
  • 7
  • 28
  • 45
Suyash Gupta
  • 23
  • 1
  • 3

1 Answers1

1

This code can help

out_list = []
req_word = "DEVOPS"
f = open("Propertiesfile.properties",'r')
for i in f.readlines():
    if(i.split("=")[0] == req_words"):
        out_list.append(i.split("=")[1:]) 
Max
  • 1,283
  • 9
  • 20