我想申请十进制格式的十进制字符串中的句子 (The temperature of $place is $value degree $unit)
将其转化为(The temperature of room is 45 degree Celsius)
申请十进制格式为十进制的字符串+数字的句子
我使用python的模板库safe_substitute
方法改变我的字符串para-metered内容。 我需要使用特定格式({0:.2f}
)将相同句子中的一个十进制值(来自上面句子的$value
)格式化。如何做到这一点的任何想法,请回应。
你为什么不使用'str.format'? – falsetru