shell - How do I parse a file and substitute the environment variables with values in Python -


I have a text file (this is called file 1.txt), it has the following lines: "Read the model $ path_1 "

How do I change the value of path 1 in this text file and write it in another file (it says file 2.txt) with the same content but expanded $ path_1 variable. There should be something like the following in my file2.txt: "Read Model / Home / Aero / Test"

Is there a parser available for this job? I was seen in the Conferpers module, but I think it needs a config file with the variable = value pair.

Regards, Evening

string. Template

  gt; & Gt; String import template & gt; & Gt; & Gt; S = template ('$ which likes $') & gt; & Gt; & Gt; S.substitute (Joe = 'Tim', what = 'Kung Pao') 'Tim Choice Kung Pao'    

Comments