Learning python ninth day

Day9:
1. Use a recursive function to be guarded against stack overflow . In the computer, the function call is achieved through the stack (Stack) This data structure, each time a function call into the stack a stack frame is increased by one, each time the function returns, the stack will be reduced one stack frame. As the stack size is not unlimited, so the number of recursive calls too, can cause a stack overflow.
2. Slice the list with:
(1) .L [0: 3] represents a start index taken from 0, until the index 3, but not including the index 3. That index 0,1,2, exactly three elements.
If the first index is 0, may further be omitted:
>>> L[:3]

['Adam', 'Lisa', 'Bart']

1 may start, two elements removed from the index:
>>> L[1:3]

['Lisa', 'Bart']

Only a  :  represents from start to finish ( L [:] is actually a copy of a new List ):
>>> L[:]

['Adam', 'Lisa', 'Bart', 'Paul']

. (2) The slicing operation may also specify the third parameter:
>>> L[::2]

[ "Adam," "Bart ']

The third parameter every N take one of the above L [:: 2] will remove one of each of two elements, i.e. a spacer take a.

 (3). For the List, since Python supports L [-1] taking the inverse of the first element, it also supports the slice countdown

 

3. The strings have a method upper () can be put into an uppercase character
>>> 'abc'.upper()

'ABC'

 

Guess you like

Origin www.cnblogs.com/zyq-666/p/11478556.html