Discuss / Python / 错误处理,打卡

错误处理,打卡

Topic source

人玉匆花

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

def str2num(s):

    if '.' in s:

        return float(s)

    return int(s)

ps:看评论try...except的方法更好。不需了解内部的问题。


  • 1

Reply