s1 = "afhjdshfhshfkjdhfjhfjdshfhfiurhkjfjhfhvjfvfdv" s2 = "argument: A value passed to a function (or method) \ when calling the function." s3 = "csjchjscjcjkdsjcsk" \ "cjdscdskcjkdsjcksdjckjs" \ "djkcjdkcjsqdjckldjckdsjckdjckjckjckdjs" text1 = """Python was created in the early 1990s by Guido van Rossum at Stichting Mathematisch Centrum (CWI, see http://www.cwi.nl/) in the Netherlands as a successor of a language called ABC. Guido remains Python’s principal author, although it includes many contributions from others. In 1995, Guido continued his work on Python at the Corporation for National Research Initiatives (CNRI, see http://www.cnri.reston.va.us/) in Reston, Virginia where he released several versions of the software. In May 2000, Guido and the Python core development team moved to BeOpen.com to form the BeOpen PythonLabs team. In October of the same year, the PythonLabs team moved to Digital Creations (now Zope Corporation; see http://www.zope.com/). In 2001, the Python Software Foundation (PSF, see http://www.python.org/psf/) was formed, a non-profit organization created specifically to own Python-related Intellectual Property. Zope Corporation is a sponsoring member of the PSF.""" ##def is_in (char, text) : ## for c in text : ## if c == char : ## return True ## return False ## ## ##def count (char, text) : ## n = 0 ## for c in text : ## if c == char : ## n += 1 ## return n ### compare returns -1, 0, or 1 when string s1 is ### less than, or equal to, or larger than s2 ##def compare (s1, s2) : ## n = min(len(s1), len(s2)) ## for i in range(n) : ## if ord(s1[i]) < ord(s2[i]) : ## return -1 ## if ord(s1[i]) > ord(s2[i]) : ## return 1 ## ## if len(s1) < len(s2) : ## return -1 ## elif len(s1) > len(s2) : ## return 1 ## else : ## return 0 text = "abbabaabbabbbabbabaaabbbbabbabbabbbbabbababbab" i = 0 while True : i = text.find("ab", i, len(text)) if i == -1 : break print(i) i += 1 #### 关于 Python 函数递归深度的默认控制和设置 ##from sys import getrecursionlimit, setrecursionlimit ## ##print(getrecursionlimit()) ## ##setrecursionlimit(2000) ## ##print(getrecursionlimit()) """ sys.setrecursionlimit(limit) Set the maximum depth of the Python interpreter stack to limit. This limit prevents infinite recursion from causing an overflow of the C stack and crashing Python. The highest possible limit is platform-dependent. A user may need to set the limit higher when they have a program that requires deep recursion and a platform that supports a higher limit. This should be done with care, because a too-high limit can lead to a crash. Python 2.0: The default value is 1000, and a rough maximum value for a given platform can be found by running a new script, Misc/find_recursionlimit.py. """