Python学习2

some built in methods:
List:
append(),
pop(),
insert()

documentation of functions:

def name_of_function():
    '''
    DOCSTRING: Information about the function
    INPUT: 
    OUTPUT: hello
    
    '''
    print("Hello")

default parameter:

def say_hello(name='NAME'):
    print('hello ' + name)

def myfunc(*args):
  print(args)

args是以tuple的形式


image.png

**kwargs传进去是keyword argument的形式,会是dictionary的类型


image.png
image.png

python string 没有append方法,用s += 'ABC'来做

reverse a string:


image.png

检查某个str有没有一个subsequence的方法:


image.png

推荐阅读更多精彩内容