a, b= 1, 2 将a和b两个变量中的最大值赋值给c (1)常规写法 if a>b: c = a else: c = b (2)表达式 c = a if a>b else b (3)二维列表 c = [b,a][a>b] (4)逻辑赋值 c = (a>b and [a] or [b])[0] 分析: 1.2为程序的基本语法不讨论 3:首先a>b的取值为True或False,而在python中True的默认值为1False的默认值为0. 可得
Python文档中有一段话: Remember that arguments are passed by assignment in Python. Since assignment just creates references to objects, there’s no alias between an argument name in the caller and callee, and so no call-by-reference per se. 我们常说参数的传递分为按值传递与按引