题解 | #表达式求值#
表达式求值
https://www.nowcoder.com/practice/9566499a2e1546c0a257e885dfdbf30d
string = input()
safe_lst = ['+', '-','*','/','(',')','0','1','2','3','4','5','6','7','8','9']
test = False
for char in string:
if char in safe_lst:
test = True
else:
test = False
break
if test == True:
print(eval(string))
if test != True:
print('unsafe input')
查看12道真题和解析