py向:对于空数据要怎么特判

P2393 yyy loves Maths II

``` t = input() ``` 直接出错,我就摊手了
by 恭叔与匠 @ 2020-03-02 17:29:27


学到了用异常判断的方法!! ``` import decimal try : a = input().split() n = len(a) ans = decimal.Decimal(0) for i in range(n) : ans += decimal.Decimal(a[i]) print(ans.quantize(decimal.Decimal('1.00000'),rounding=decimal.ROUND_HALF_UP)) except : print('0.00000') ```
by 恭叔与匠 @ 2020-03-02 17:48:32


|