python定義函數一定要用return嗎?
python中定義函數時,選擇性地返回一個值給調用方,需要用return 1、示例代碼 def showUser(user): s = '' for i in range(0, len(user)): s += str(user[i]) + ',' return s akm = [1, 2, 3, 4, 5] bkm = showUser(akm) print(bkm) 2、示例結果 1,2,3,4,5,
python定義函數一定要用return嗎?
python中定義函數時,選擇性地返回一個值給調用方,需要用return 1、示例代碼 def showUser(user): s = '' for i in range(0, len(user)): s += str(user[i]) + ',' return s akm = [1, 2, 3, 4, 5] bkm = showUser(akm) print(bkm) 2、示例結果 1,2,3,4,5,