-1
请解释Python如何评估这个字符串,以便可以设置一个字的值大于字符串中的另一个字的值?如何b> n。Python字符串和排序?
def not_bad(s):
n = s.find('not')
b = s.find('bad')
if n != -1 and b != -1 and b > n:
s = s[:n] + 'good' + s[b+3:]
return s
发现返回的位置,那么你真的比较数字。 http://docs.python.org/2/library/string.html#string.find – sachleen
请参阅[这个问题](http://stackoverflow.com/questions/4806911/string-comparison-technique-used-by- python) – eebbesen
尝试用_'调用你的函数当乐队演奏lambada'_时,萨克斯演奏者弹出错误音符。 – pillmuncher