函数

函数的定义

def demo1(*args,**kwargs):
    print(args)
    print(kwargs)

def demo2(x,y):
    sum_num = x+y
    return sum_num,x,y

if __name__=='__main__':
    #运行demo1
    gl_num = (1,2,3)
    gl_dict = {'class':'python','tool':'pycharm'}
    demo1(*gl_num,**gl_dict)

    #运行demo2
    sum_num,x,y = demo2(1,2)
    print(sum_num,x,y)

运行结果:

>>> 
================ RESTART: C:\Users\Administrator\Desktop\p.py ================
(1, 2, 3)
{'class': 'python', 'tool': 'pycharm'}
3 1 2
>>> 

 

eval()函数:

a = "{'name':'tom'}"
b = eval(a)
print(b,type(b))

运行结果:

>>>
{'name': 'tom'} <class 'dict'>
>>> 

 

上一篇:[洛谷日报#204] StackEdit——Markdown 编辑器的功能介绍


下一篇:个人任务五——事后诸葛亮项目回顾204吴绍平