返回列表 發帖

格式化輸出 (一)

  1. pi=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. pi=3.14159
  2. print("circle%.2f"%pi)
  3. print("circle%.4f"%pi)
  4. print("circle%05.2f"%pi)
  5. print("circle%.s"%pi)
  6. print("circle%.f"%pi)
  7. print("circle%.d"%pi)
複製代碼

TOP

  1. pi= 3.14
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼

TOP

  1. pi=3.14159
  2. print("radius is %.2f"%pi)
  3. print("radius is %.4f"%pi)
  4. print("radius is %05.2f"%pi)
  5. print("radius is %f"%pi)
  6. print("radius is %d"%pi)
  7. print("radius is %s"%pi)
複製代碼

TOP

返回列表