python的一个bug,希望各位看一下

img


不知道为什么b语法报错
print("计算器1.0)
a= int((input(“请输入:_))
b=input("请选择符号:")
c=int((input(“请输入“))

是括号的原因把,第2行和第4行input前面那个括号去掉就可以了,然后如果要将输入的式子和它的结果输出,还可以增加一个输出语句。

修改如下:

参考链接:


https://www.runoob.com/python/att-string-format.html

http://c.biancheng.net/view/4301.html

https://blog.csdn.net/weixin_50853979/article/details/124997408



print("计算器1.0")
a= int(input("请输入:")) # 去掉表达式里多余的括号
b=input("请选择符号:")
c=int(input("请输入:"))  # 去掉表达式里多余的括号

# https://blog.csdn.net/qq_45726327/article/details/115042863
# https://www.runoob.com/python/att-string-format.html
# http://c.biancheng.net/view/4301.html
# https://blog.csdn.net/weixin_50853979/article/details/124997408
# 输出式子及其结果
print("{:f}{:s}{:f}={:f}".format(a,b,c,eval(str(a)+str(b)+str(c))))


img