Let's suppose I get some string and set it to variable - it can't be created as f-string:
str1 = 'date time for {val1} and {val2}'
Then variables inside the string initialized:
val1 = 1
val2 = 77
Calling print(str1)
will return 'date time for {val1} and {val2}'
. But I would like to get
'date time for 1 and 77'
Is there any function to make a string as a F string? So I want to call something make_F(str1)
and get f-string
PS I cant use dict {'val1':1, 'val2':77}
with .format
because don't know which variables will be needed in the string. I just want magic happen with F-string.
val2
in the sample code