第一个if语句,判断是是不是如u "a e k" j这类字符串,elif判断是不是u "a" e这类字符串,最后else为其他无双引号情形。
while True:
try:
strlist = input().split(' ')
l = len(strlist)
c = 0
b = []
newlist = []
for i in range(c, l):
if strlist[i][0] == '"' and strlist[i][-1] != '"':
temp = []
b.append(i)
temp.append(strlist[i].replace('"', ''))
for j in range(i+1, l):
if strlist[j][-1] == '"':
b.append(j)
temp.append(strlist[j].replace('"', ''))
break
else:
b.append(j)
temp.append(strlist[j])
str1 = ' '.join(temp)
newlist.append(str1)
elif strlist[i][0] == '"' and strlist[i][-1] == '"':
newlist.append(strlist[i].replace('"', ''))
else:
if i in b:
continue
else:
newlist.append(strlist[i])
print(len(newlist))
for i in newlist:
print(i)
except:
break
while True:
try:
strlist = input().split(' ')
l = len(strlist)
c = 0
b = []
newlist = []
for i in range(c, l):
if strlist[i][0] == '"' and strlist[i][-1] != '"':
temp = []
b.append(i)
temp.append(strlist[i].replace('"', ''))
for j in range(i+1, l):
if strlist[j][-1] == '"':
b.append(j)
temp.append(strlist[j].replace('"', ''))
break
else:
b.append(j)
temp.append(strlist[j])
str1 = ' '.join(temp)
newlist.append(str1)
elif strlist[i][0] == '"' and strlist[i][-1] == '"':
newlist.append(strlist[i].replace('"', ''))
else:
if i in b:
continue
else:
newlist.append(strlist[i])
print(len(newlist))
for i in newlist:
print(i)
except:
break