def sstrip(a):
b=raw_input("enter the string to be stripped off")
i=a.strip(b)
print i
k=raw_input("enter the string")
sstrip(k)
输出:地带功能不按预期方式工作
enter the string - is it available?
enter the string to be stripped off - is
t available?
在上述程序中,i是2个字符串的一部分是与它..“它”是一个中word.In那我也被剥夺了。
有人能帮助我
你觉得'a.strip(b)'做什么? “a”是否应该参与剥离动作? ;) – alfasin
如果它不符合预期,请阅读[文档](https://docs.python.org/3/library/stdtypes.html#str.strip) –
我认为OP的难点在于strip()是唯一的我能想到的地方是一组字符被指定为一个字符串。而且他显然并不孤单,因为2.7.13文档中提到“字符参数不是前缀或后缀;相反,其值的所有组合都被剥离”。这一点最近被添加了。 – BoarGules