Python string formatting when string contains “%s” without escaping

后端 未结 4 1319

When formatting a string, my string may contain a modulo \"%\" that I do not wish to have converted. I can escape the string and change each \"%\"

4条回答
  •  清酒与你
    2020-12-31 04:14

    Not really - escaping your % signs is the price you pay for using string formatting. You could use string concatenation instead: 'Day old bread, 50% sale ' + whichday if that helps...

提交回复
热议问题