s = "python
is
good "
remap = {
ord(' '): ' ', # 替换成空格
ord('
'): None,
ord('
'): None # Deleted
}
a = s.translate(remap)
print(a)
使用了translate不用在replace, , , 了。
s = "python
is
good "
remap = {
ord(' '): ' ', # 替换成空格
ord('
'): None,
ord('
'): None # Deleted
}
a = s.translate(remap)
print(a)
使用了translate不用在replace, , , 了。