我需要从字符之前出现的部分去除字符串':'
,其中':'
可能出现多次。例如:
input: 'Mark: I am sending the file: abc.txt'
output: 'I am sending the file: abc.txt'
Run Code Online (Sandbox Code Playgroud)
我的功能是这个(Python代码)
def process_str(in_str):
str_list = in_str.split(':')[1:]
out_str = ''
for each in str_list:
out_str += each
return out_str
Run Code Online (Sandbox Code Playgroud)
我得到的输出'I am sending the file abc.txt'
没有第二个':'
. 有没有办法纠正这个问题?也可以使这段代码在时间和空间复杂度上更有效吗?