我刚开始学习python。我正在尝试将计算器作为介绍项目。另外我写了:
if operation == "Addition":
print("The answer is: " +str(num1+num2))
稍后程序会询问您要执行什么操作。我不想输入 Addition,而是按键盘上的 + 键。我可以这样做吗?我想 + 键有某种我需要找到的代码?
最佳答案
op = input('please input the operation sign')
num1 = input('Enter first number')
num2 = input('Enter second number')
if (op == '+'):
print("The answer is: " + str(int(num1) + int(num2)))
else:
quit()
关于python - 如何使用 '+' 作为输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62180988/