返回列表 發帖

格式化輸出 (一)

  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"%i)
  6. print("圓周率為%d"%pi
  7. print("圓周率為%s"%pi)
複製代碼

TOP

  1. pi=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%f"%pi)
  5. print("圓周率為%d"%pi)
  6. print("圓周率為%s"%pi)
  7. print("圓周率為%05.2f"%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

返回列表