如何有选择地在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
陪伴而非守候
白猪掌柜的
相关分类