while True:
"""
使用标志位,注意上引号的出现,如果出现过一次上引号,那么当前参数结束的标志不是space而是下一个单引号
"""
try:
string = input()
result = []
word = ''
appear_left_quotation =False
for char in string:
if char == " ":
if not appear_left_quotation:
result.append(word)
word = ""
else:
word += char
elif char == "\"" and not appear_left_quotation:
word += char
appear_left_quotation = True
elif char == "\"" and appear_left_quotation:
word += char
result.append(word)
word =""
appear_left_quotation =False
else:
word+=char
result.append(word)
print(len(result))
for line in result:
print(line)
except:
break
HW.参数解析
猜你喜欢
转载自blog.csdn.net/dpengwang/article/details/92946886
今日推荐
周排行