我阅读Mark Pilgrim的深入Python 3,并已在这个现在凝视了大约一个小时:http://getpython3.com/diveintopython3/strings.html#common-string-methodsPython的String类计数()方法
>>> s = '''Finished files are the re-
... sult of years of scientif-
... ic study combined with the
... experience of years.'''
>>> s.lower().count('f')
6
在多线串为例进行说明,我不明白为什么s.lower().count('f')
返回6而不是3.我已经确认它返回6.当然,朝圣者甚至在他的笔记中指出它实际上是6,但并不能解释为什么。
有人可以帮我吗?谢谢!
四个答案?和12总upvotes? (至今)。为了数f? – alan
我会让你高兴,@alan! –