替换小数点后两位或后一位的浮点数import re

text = '12.0~13.00'

re.sub('[0-9]*\.[0-9]{2}|[0-9]*\.[0-9]{1}', '999', text)