Discuss / Python / 能不能请教一个问题 感谢

能不能请教一个问题 感谢

Topic source

#下面这段为啥总是报错呢,如果没有finally就没有执行结果 def str2num(s): return int(s)

ss = '99 + 88 + 7.6' try: ns = map(str2num,ss) except Exception as e: print(e) ns = [11,22,33] finally: print(reduce(lambda x, y:x + y,ns))

上面打错了s = ['99','88','7.6'],不知道为啥总是报错

Linda00-00

#3 Created at ... [Delete] [Delete and Lock User]

因为int('7.6')出错


  • 1

Reply