python的 raw_input 用法。

2024-12-29 22:22:26
推荐回答(1个)
回答1:

record = []
while True:
  info = []
  userInput = raw_input('Enter something: ')
  if userInput == "exit":
    break
  else:
    info=userInput.split(",")
    record+=[info]
print record

输入的时候把内容用逗号隔开.

输入exit终止循环.

Enter something: hello, hi

Enter something: good, bad

Enter something: red, green

Enter something: exit

[['hello', ' hi'], ['good', ' bad'], ['red', ' green']]

>>>