Python学习笔记3

#反转过程
def add(x,y):
    return x+y

params = (1,2)

add(*params)
#3

def story(**kwds):
    return 'Once upon a tinme,there wa s '
            '%(job)s called %(name)s' %kws

def power(x,y,*others):
    if others:
        print 'Received redundat parameters:',others
    return pow(x,y)

def interval(start,stop=None,step=1):
    'Imitates range() for step>0'
    if stop is None:
        start,stop = 0,start
    result = []
    i = start
    while i<stop:
        result.append(i)
        i+=step
    return result

#内建字典 所有变量
x = 1
scope = vars()
print scope['x']
#1
scope['x']+=1
print x
#2

#改变全局变量
x = 1
def change_global():
    global x
    x = x+1

change_global()
print x
#2
原文地址:https://www.cnblogs.com/longdidi/p/3162778.html