Python 函数的三种定义方式

无参:应用场景仅仅只是执行一些操作,比如与用户交互,打印
有参:需要根据外部传进来的参数,才能执行相应的逻辑,比如统计长度,求最大值最小值
空函数:设计代码结构

def my_max(x,y):
    if x > y:
        # print(x)
        return x
    else:
        # print(y)
        return y

res=my_max(1,2)
print(res)

res=max(1,2)
print(res)

def foo():
    print('-=----')
    return 123
    print('-=----')
    print('-=----')
    print('-=----')
foo()

def main():
while True:
sql=input('>>: ').strip()
if not sql:continue
cmd_info=sql.split()
cmd=cmd_info[0]


if cmd == 'select':
select(cmd_info)



main()

 

 

posted @ 2017-07-21 01:32  刘小伟  阅读(815)  评论(0编辑  收藏  举报