返回列表 發帖

格式化輸出 (一)

本帖最後由 tonyh 於 2019-7-12 14:08 編輯

  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("圓周率為%.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("圓周率為%.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("圓周率為%.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("圓周率為%.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("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print(")
複製代碼

TOP

返回列表