使用 sub()函数

  1. import re
  2.  
  3. str = "China is a great country"
  4. x = re.sub("\s", "9", str)
  5. print(x)