fork download
  1. import sys
  2.  
  3. def input_int():
  4. while True:
  5. x = input()
  6. try:
  7. x = float(x)
  8. if int(x)==float(x):
  9. return int(x)
  10. print("件數應該整數,請重新輸入")
  11. continue
  12. except:
  13. print("請勿輸入非數字之文字,請重新輸入")
  14. continue
  15. print("請輸入總件數:")
  16. totalpkg = input_int()
Success #stdin #stdout 0.02s 9232KB
stdin
a
1.5
1
stdout
請輸入總件數:
請勿輸入非數字之文字,請重新輸入
件數應該整數,請重新輸入