Python:if语句中冒号的目的是什么? [英] Python : What is the purpose of a colon in an if statement?
本文介绍了Python:if语句中冒号的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在下面有这段python代码。
I have this piece of python code below.
def m(list):
v = list[0]
for e in list:
if v < e: v = e
return v
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
for row in values:
print(m(row), end = " ")
结果是5,33。
如果v< e:v = e ?
Can somebody explain me that following if statement if v < e: v = e
?
推荐答案
if v < e: v = e
可以读取:如果v小于e,则使v值为e。
can be read: "If v is less than e, make v the value of e."
如上所述,你应该换一个新行让它更容易理解:
As above you should put a new line to make it read easier:
if v < e:
v = e
这篇关于Python:if语句中冒号的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文