Is there some python way to convert a text (from a file for example) into a format string?
I mean for a text file:
this is a {format}
string.
Load it in python and have it become like the triple quotes format string:
var = """this is a {format}
string."""
I know how to just read the file and replace the curly braces, but I was wondering if there is already something that does this.
Thanks
Edit: This is the code I've tried:
with open('file.txt', 'r') as rs:
lines = rs.readlines()
text = ','.join(lines)
print(text)
text.format(format='something_else')
print(text)
It just prints the text file. I'm looking to know if there is a more pythonic way then me having to write a class that does this. Thanks