【发布时间】:2020-09-06 04:15:59
【问题描述】:
我正在寻找有关 Python 3 中字符串操作的帮助。
输入字符串
s = "ID bigint,FIRST_NM string,LAST_NM string,FILLER1 string"
期望的输出
s = "ID,FIRST_NM,LAST_NM,FILLER1"
基本上,目标是删除输入字符串中所有出现的空格和逗号之间的任何内容。
非常感谢任何帮助
【问题讨论】:
-
这能回答你的问题吗? Replace a string located between
-
",".join(x.split()[0] for x in s.split(","))?
标签: python python-3.x string replace