题解 | #参数解析#
参数解析
http://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677
while True:
try:
a = list(input())
k = 0
d = []
for i in range(len(a)):
if(a[i] == '"'): #记住引号的位置
d.append(i)
test = 0
for i in range(0,len(d),2):
for j in range(d[i],d[i+1] + 1): #每两个引号之间的字符串的空格用$代替
if(a[j] == ' '):
a[j] = '$'
a = ''.join(a)
a = a.split() #按空格分开
for i in range(len(a)):
a[i] = a[i].replace('"','') #去掉引号
a[i] = a[i].replace('$',' ') #将$还原为空格
print(len(a)) #按要求输出
for i in range(len(a)):
print(a[i])
except:
break
华为机试题解(prod.by kedao) 文章被收录于专栏
华为实习机试题解