python的輸入輸出格式

2021-08-25 22:51:04 字數 810 閱讀 5147

1.輸入格式(1)直接輸入

raw_input('提示詞')

(2)將輸入的值賦值給passwd

passwd = raw_input('請輸入你的密碼:')

(3)將輸入的值轉換型別賦值給price

price = float(raw_input('水果的單價:'))

2.輸出格式(1)print '格式化字串' % 變數1

print '你的密碼為 %d '  %password

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

print '水果的單價為 %.2f 您購買了 %.2f 總**為 %.3f '%(price,weight,money)

(3)格式化字串含義

%s   字串str

%f   float型別 %.2f 輸出小數點後兩位 %.0f 小數點後輸出0位

%d   整型 %06d不到6位就補0,是6位或超過6位,該多少就顯示多少

%%   輸出%

python的簡單輸入輸出格式

1.python的輸出 python2 print 要列印的字串 python3 print 要列印的字串 2.python的輸入 python2 raw input 接收字串的資料 input 只能接收數值 型別 python3操作 沒有raw input,只有input,python3中為了避免...

c 輸入輸出格式控制

使用這些格式需要宣告包含 long flags const 返回當前的格式標誌。long flays long newflag 設定格式標誌為newflag,返回舊的格式標誌。long setf long bits 設定指定的格式標誌位,返回舊的格式標誌。long setf long bits,lo...

ACM常用輸入輸出格式

因為acm新人對於acm題目中處理輸入輸出存在一些疑惑,於是在這裡記錄幾種常用的輸入輸出方法。int n scanf d n while n c int a while scanf d a eof c int a while cin a c int n while scanf d n n 0 c i...