从字符串中删除空格

put*_*uti 0 python

如何将字符串转换为必需的字符串(ans)?这是python中的简单字符串操作.

s = '(107, 163, 138, 255)'


ans = '(107,163,138,255)'
Run Code Online (Sandbox Code Playgroud)

Jos*_*ana 5

使用replace方法用空格替换空格:

>>> s = '(107, 163, 138, 255)'
>>> s.replace(" ", "")
'(107,163,138,255)'
Run Code Online (Sandbox Code Playgroud)