习题17:过滤注释
作者:
今年说话算话 | 来源:发表于
2017-02-22 15:32 被阅读0次def solution(string,markers):
#your code here
def get_lines(string):
l = []
k = 0
while True:
t = string.find('\n', k)
if t >= 0:
l.append(string[k:t+1])
k = t + 1
else:
l.append(string[k:])
break
return l
lines = get_lines(string)
r = ''
for line in lines:
flag = False
t = ''
for e in line:
if e in markers:
flag = True
elif e == '\n':
t = t.rstrip()
flag = False
if not flag:
t += e
r += t
return r.rstrip()
本文标题:习题17:过滤注释
本文链接:https://www.haomeiwen.com/subject/pmxmwttx.html
网友评论