Python 函數的三種定義方式
阿新 • • 發佈:2017-07-21
true int 交互 方式 邏輯 pre pri [0 操作
無參:應用場景僅僅只是執行一些操作,比如與用戶交互,打印
有參:需要根據外部傳進來的參數,才能執行相應的邏輯,比如統計長度,求最大值最小值
空函數:設計代碼結構
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()
Python 函數的三種定義方式