Python默認遇到回車的時候,輸入結束。所以我們需要更改這個提示符
設置stopword="xxx"
1 stopword = ''#修改輸入終止符為空行 2 str = '' 3 print('請輸入內容【單獨輸入‘‘保存退出】:') 4 for line in iter(input,stopword): 5 str+=line 6 print(str)
結果:

是不是很簡單
Python默認遇到回車的時候,輸入結束。所以我們需要更改這個提示符
設置stopword="xxx"
1 stopword = ''#修改輸入終止符為空行 2 str = '' 3 print('請輸入內容【單獨輸入‘‘保存退出】:') 4 for line in iter(input,stopword): 5 str+=line 6 print(str)
結果:

是不是很簡單
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。