题解 | #表达式求值#

表达式求值

http://www.nowcoder.com/practice/9566499a2e1546c0a257e885dfdbf30d

跟HJ50: 四则运算有同样的解答方式

while True:
    try:
        inpt = input()
        inpt = inpt.replace('[','(')
        inpt = inpt.replace(']',')')
        inpt = inpt.replace('{','(')
        inpt = inpt.replace('}',')')
        print(int(eval(inpt)))
    except:
        break

全部评论

相关推荐

点赞 评论 收藏
分享
评论
6
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务