python輸入輸出

2021-08-20 13:52:56 字數 547 閱讀 6911

輸出:print('something' , 'something')

遇到逗號顯示空格,'some'some直接列印出來

print('a+b=','100+200')

a+b= 100+200

print('please','not''do' 'this')///逗號是空格,而空格不是空格,『some』 裡面作為字元處理

please notdothis

輸入:name = input()  //等待輸入

liuhao  你所輸入的

>>> name          //此時儲存好,進行驗證

'liuhao'

print('hello,',name)

hello, liuhao

此處name作為字元儲存 name == 『liuhao』,而print如之前所說,逗號為空格,『  』裡面為字元

name = input('please enter your name: ')
這樣會更好,因為括號會提示你

python輸入輸出

對於輸入輸出操作,我們可以用raw input或print語句實現,但我們也可以用檔案來實現,下面我們將討 件的使用。我們可以用檔案類來建立乙個檔案物件,並用它的read readline write方法實現檔案的讀寫操作。當檔案使用完畢後,你應該使用close方法,以釋放資源。下面是乙個使用檔案的...

python 輸入輸出

input 是輸出乙個數字 raw input是輸入一行字串 while true try g lambda map int,raw input split a,b g print a b except exit 0 這裡用了lambda 然後也可以直接 a,b map int,raw input ...

Python 輸入輸出

總結幾個常用的.python提供了 input 置函式從標準輸入讀入一行文字,預設的標準輸入是鍵盤。input 可以接收乙個python表示式作為輸入,並將運算結果返回。usr bin python3 str input 請輸入 print 你輸入的內容是 str str.format 1 prin...