from string import Template temp=Template("select ${field} from ${table}") text=temp.substitute(field="*",table="test") print(text)