Print a numeric variable

MyString = "abc" +  str(MyValue) + "def"
MyString += "hij"

Insert value strings into a string

#Insert variables directly (NOTE THE 'f' BEFORE THE STRING!! - requried for this)
my_string = f"Something {string_a} blah {string_b}"

#Original typical method
my_string = "Something {} blah {}".format(string_a, string_b)

#Or you can name the insertion points with keywords:
my_string = "Something {str_a} blah {str_b}".format(str_b=string_b, str_a=string_a)

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *