python基礎 輸入輸出

2022-07-05 13:30:25 字數 566 閱讀 1574

1、輸入字串。

name=input()   or name=input('please input a string')  

這樣可以接收乙個字串,包括空格,都可以輸入。只有回車不接受,作為結束符,第二個為提示資訊的新增。

1

輸入多個數字

3 a=input().split('

') #預設空格,可改為其他

4 n=int(a[0

])

5 m=int(a[1])

or  n,m=input().split()  

輸入兩個數字或字串,以空格隔開,空格不接受(也可以改為逗號)

迴圈輸入(oj)

1

while

(true):

2try

: 3 a=input()

4print(a)

5except:

6break

輸出:print(name,"mary",sep=' *此處空格* ',end=' *此處結尾* ') 

python基礎 輸入輸出

input print 知識點 1.input預設接收使用者輸入內容為字串型別 2.print直接輸出字串內容 card id input 請輸入學號 pwd input 請輸入密碼 print card id print type card id print pwd 1.print列印字串 pri...

Python基礎 輸入輸出

基本格式 常用格式化字元 含義 s 字串 d 有符號十進位制的整數,06d 輸出的整數顯示位數,不足的地方使用0補全 f浮點數 2f表示顯示小數點的後兩位 輸出 變數輸出例項需求 定義整數變數 student no,輸出 我的學號是 000001 student no 1 print 學號是 06d...

python基礎輸入輸出

輸出 print 加上 字串就可以輸出 print 函式也可以接受多個字串,用逗號 隔開,結果 會變成空格 print 函式中可以直接進行簡單的數 算 print 字串 輸出變數 表示拼接 兩邊的變數型別必須保持一致 格式化輸出 print 字串 s,s,s 對應佔位符的內容 s佔位符 str強制轉...