如何有选择地在Python字符串中转义百分比(%)?
我有以下代码
test = "have it break."selectiveEscape = "Print percent % in sentence and not %s" % testprint(selectiveEscape)
我想获得输出:
Print percent % in sentence and not have it break.
实际发生了什么:
selectiveEscape = "Use percent % in sentence and not %s" % testTypeError: %d format: a number is required, not str
皈依舞
慕码人8056858
相关分类