04 python基本的輸入輸出函式

2022-01-24 06:03:29 字數 577 閱讀 6872

(1)輸入函式簡介

字串變數 = input("提示資訊:")
(2)巢狀輸入形式

函式解釋

int(x)

將 x 轉換為乙個整數

float(x)

將 x 轉換到乙個浮點數

price = float(input("請輸入資料:"))

(1)輸出函式簡介

在 python 中可以使用print函式將資料進行輸出。

(2)格式化輸出

不同的輸出格式

格式化字元

含義%s

字串%d

有符號十進位制整數,%06d表示輸出的整數顯示位數,不足的地方使用0補全

%f浮點數,%.2f表示小數點後只顯示兩位

%%輸出%

print("格式化字串" %變數1)

print("格式化字串" %(變數1, 變數2...))

Tutorial C 04 基本輸入輸出

putchar a 字元輸出函式,其功能是在終端 顯示器 輸出單個字元。putchar n 支援轉義換行 putchar 77 可以直接注入ascii的字元值 接收使用者從鍵盤上輸入的乙個字元,會以返回值的形式返回接收到的字元 printf函式叫做格式輸出函式,其功能是按照使用者指定的格式,把指定的...

Python 基本輸入輸出

1.輸出 print hello,world python3中print需要加 print hello,world 多個字串之間用 逗號連線 print hello world 且遇到逗號會輸出乙個空格。2.注釋 python中用 注釋 print hello 3.變數 python中定義變數時不需...

python的基本輸入輸出

python的輸入輸出 輸入 input raw input 1.input 用於收集數字輸入 a input input a input a 2 a 可以輸入乙個變數 a input inputa input a a a 無法接收字元 a input input a input a b trace...