我想从输入 'x+y' 中删除“+”号,其中 x 和 y 是一个字符串(单个数字)并打印结果。
比如我输入5+7应该显示57
代码如下:
opr = input("Enter string").strip("+")
print(opr)
这段代码没有删除“+”号。
请您参考如下方法:
你可以使用替换
opr = input("Enter string").replace("+","")
print(opr)
我想从输入 'x+y' 中删除“+”号,其中 x 和 y 是一个字符串(单个数字)并打印结果。
比如我输入5+7应该显示57
代码如下:
opr = input("Enter string").strip("+")
print(opr)
这段代码没有删除“+”号。
请您参考如下方法:
你可以使用替换
opr = input("Enter string").replace("+","")
print(opr)