s = "python\n\t\ris\ngood\t"
remap = {
    ord('\t'): ' ',  # \t替换成空格
    ord('\n'): None,
    ord('\r'): None  # Deleted
}
a = s.translate(remap)
print(a)

使用了translate不用在replace,\t,\n,\r了。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
  • 2021-11-24
  • 2021-08-28
  • 2021-11-10
猜你喜欢
  • 2022-12-23
  • 2021-07-26
  • 2021-12-23
  • 2021-11-07
  • 2021-11-15
  • 2021-10-28
相关资源
相似解决方案