Python题解 | #参数解析#
参数解析
https://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677
import sys while True: try: s = input() res = [] i = 0 flag = 0 while i < len(s): if s[i] == ' ': res.append(s[flag:i]) flag = i + 1 if s[i] == '"': j = i + 1 while j < len(s): if s[j] == '"': res.append(s[flag+1:j]) flag = j + 2 i = j + 1 break j += 1 i += 1 if flag < len(s): res.append(s[flag:]) print(len(res)) for i in res: print(i) except: break