在Python 2.x
这也是为什么不能像这样使用它的原因:
lambda x: print x
请注意,
(expr)它不会创建元组(结果为
expr),但
,会创建。在方寸之间这种可能的结果
print (x),并
print (x,y)在Python 2.7
(1) # 1 -- no tuple Mister!(1,) # (1,)(1,2) # (1, 2)1,2 # 1 2 -- no tuple and no parenthesis :) [See below for print caveat.]
但是,由于
,以特殊的方式处理, 并且不会
创建元组。对
,与否之间采取不同的行动。
快乐的编码。
print
Python 2中的此行为可以更改为Python 3:from future import print_function



