我有一个字符串如下:
”这1只是1,而1只是一个数字。 1 +1等于2”
当我想使用python格式时,它将类似于:
var = 1
test = "This {} is just a {} and {} is just a number. And {} + {} is equal to 2".format(var,var,var,var,var)
但是我想知道python中是否可以快速替换str.format()以避免重复。像这样:
test = "This {} is just a {} and {} is just a number. And {} + {} is equal to 2".format(var*)