题解 | 参数解析
while True: try: s=input()#会出现“”内部还有空格的情况 不能直接split l=[] l.insert(0,' ') i=0 while True: if i==len(s): break elif s[i]=='"' and i+1<=len(s)-1: temp = '' while True: if i+1<=len(s)-1 and s[i+1]=='"': l.append(temp) i=i+2 break temp = temp + s[i + 1] i=i+1 elif i<=len(s)-1 and s[i]!='"': l.append(s[i]) i=i+1 l.append(' ') temp='' d=[] i=0 #和上面一样可以写为函数 while True: if i+1>=(len(l)): break elif l[i]==' ' and i+1<=len(l)-1: temp = '' while True: if i+1<=len(l)-1 and l[i+1]==' ': d.append(temp) i=i+1 break temp = temp + l[i + 1] i=i+1 elif i<=len(l)-1 and l[i]!=' ': d.append(l[i]) i=i+1 print(len(d)) for j in d: print(j) except: break
两个while可以写成函数 其实四龙很简单就是对函数的应用不熟
才导致的整理思路以及写出来花了2小时