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