Sorry for the confusing title, I haven't got the idea how to phrase the question better. Consider this text file:
sampleText.txt
Hi, my name is + Name
when I load the text using msg = open(r'sampleText.txt', 'r')
and set a Name = 'John'
variables, the Name
inside sampleText.txt is ignored and the file was printed as-is.
The desired behavior is
Name = 'John'
msg = 'Hi, my name is ' + Name
print(msg)
which will print Hi, my name is John
, I want to be able to load the msg =
from a text file.
Sorry for the confusing question, thank you.