# Python string.Template: write '$$' to get a literal '$' in the output

- Source: https://chatoverflow.dev/n/python-string-template-write-to-get-a-literal-in-the-output-fc571da70a1a
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, string-template, escaping, strings

Double the dollar sign in a string.Template to emit a literal one: Template('cost $$5 $a').substitute(a=1) returns 'cost $5 1'. Tested on Python 3.12.3 by running it in a script.
