First of all, you try to re-invent wheel. If you want to make html/xml etc. page from python - there are already libraries/frameworks and tutorials for this, that will suit you much better.
However, if it's just he beginning of your programming journey, string manipulation is one of first steps.... however you also have tons of tutorials for this. Python has multiple methods to format strings (best depends on usage, really)... e.g.
Basically, string documentation is where you want to look (also, tutorials above will do the trick as well)
What you are attempting to use here is using decorators - you've possibly looked to tutorial about decorators instead strings (this is quite nice and easy example to learn decorators, but decorators itself are quite complex for starters and can be confusing...)
For basic idea, decorators are methods, that wraps around another methods... let's say, you want to log time before method and after it. You could do that in that methods body, but your method should only be focused on doing one thing. E.g. method add
should only add not, measure time, add, then measure time. Also, this binds measuring to your method - therefore you cannot use your method without measurement. Doesn't sound too flexible, and starts to be bit messy too...
So decorator is a nice way to have your 'inner' method body clean and focused on its role, but extending it with another functionality... Wrapping method and inner method are also independent (most of cases), and can be quickly separated... Also imagine, that you want to measure time of 'a lot of' your methods, but not every - so you put that decorator only with those methods, you want.