多行輸入
import sys strList = [] for line in sys.stdin: #沒有當接受到輸入結束信號就一直遍歷每一行 tempStr = line.split()#對字符串利用空字符進行切片 strList.extend(tempStr)# # 多行輸入 # 1.利用異常處理機制 # ctrl+c結束輸入 # windows中 lines=[] while True: try: lines.append(input()) except: break print(lines) #利用標准輸入輸出 #Linux中使用ctrl+d結束輸入 import sys lines=sys.stdin.readlines() print(lines) #標准輸入輸出 #Linux中使用ctrl+d結束輸入 import sys if __name__ == '__main__': strlist=[] for line in sys.stdin: strt=line.split() strlist.extend(strt) #增加判斷 lines=[] while True: try: strs=input() if strs=='': break else: lines.append(strs) except: break print(lines) #!/usr/bin/python3 #_*_ coding:utf-8 _*_ strList=[] while True: strin=input() if strin=='': break else: strList.append(strin) print(strList)