python3如何進行多行輸入?

時間 2021-06-02 22:58:04

1樓:奴隸罷了

lines =

words = input("請輸入內容(單獨輸入':w'儲存退出):")

while words != ':w':

words = input()

print(lines)

':w'字串是停止的字串,而且不會加入到lines列表中.

可以用writelines()方法把lines裡的資料寫到檔案裡,Down!

2樓:勞里林

Raw input across multiple lines in Python

sentinel

='end'

# 遇到這個就結束

lines=

forline

initer

(input

,sentinel

):lines.(

line

)#如果想要提示,可以這樣:

from

functools

import

partial

inputNew

=partial

(input

,'Input something pls:\n'

)sentinel

='end'

# 遇到這個就結束

lines=

forline

initer

(inputNew

,sentinel

):lines.(

line

)'''

Input something pls:

萌Input something pls:

萌Input something pls:

噠Input something pls:

!Input something pls:

endIn [20]: ''.join(lines)Out[20]: '萌萌噠!''''

python語言如何進行學習?

ChengZhong.Shen 可以嘗試以下路徑 入門 MITx 6.00.1x Introduction to Computer Science and Programming Using Python 如果有時間,可以學習一下cs50,學到指標就可以了,裡面的練習很有用。高階 cs61A htt...

Python3如何順利完成 環境搭建

最近剛好寫了篇部落格 Python 應用開發最佳實踐 環境搭建篇 這是和團隊裡的工程師交流總結的最適合入門使用的 Python 開發環境搭建方案。文章裡詳細介紹了一些現代化的配置方案,並針對 Python 社群中有關環境配置的常見問題給出了價效比最高的解決方案。目前部落格還沒完整寫完,但足夠小白使用...

python3如何填充單元格背景顏色?

慕然 Win32 開啟EXCEL 要處理的excel檔案路徑 out.file是檔案絕對路徑 要處理的excel頁 WinSheet WinBook.Worksheets Sheet1 單元格新增顏色 WinSheet.Cells 1,1 Interior.ColorIndex 3 或者Range ...