题解 | #参数解析#
参数解析
https://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677
#用的递归的方法, 遇到“”时进行一个内部小循环,返回新的大循环的值
s = input()
n =len(s)
line = []
def canshu(k,n):
d = ''
for i in range(k,n):
if s[i] == ' ':
if d != '':
line.append(d)
d = ''
elif s[i] == '"':
for j in range(i+1,n):
if s[j] == '"':
line.append(s[i+1:j])
return canshu(j+1,n)
else:
d += s[i]
if i == n-1:
line.append(d)
canshu(0,n)
print(len(line))
for i in line:
print(i)


OPPO公司福利 1172人发布