欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳談python中冒號(hào)與逗號(hào)的區(qū)別

 更新時(shí)間:2018年04月18日 09:36:38   作者:langzi7758521  
下面小編就為大家分享一篇詳談python中冒號(hào)與逗號(hào)的區(qū)別,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

注意if\while\for等(或函數(shù)定義)語(yǔ)句在結(jié)尾處包含一個(gè)冒號(hào)——我們通過(guò)它告訴python下面跟著一個(gè)語(yǔ)句塊。

--------------冒號(hào)的用法

if guess == number:
print 'Congratulations, you guessed it.' # New block starts here
print "(but you do not win any prizes!)" # New block ends here
elif guess < color="#ff0000">:
print 'No, it is a little higher than that' # Another block
# You can do whatever you want in a block ...
else:
print 'No, it is a little lower than that' 
--------------
def printMax(x, y): 
'''輸出最大的2個(gè)數(shù).
2個(gè)數(shù)值必需是整數(shù).'''
x = int(x) # convert to integers,
if possible
y = int(y)
if x > y: 
print x, 'is maximum'
else:
print y, 'is maximum'
========逗號(hào)的特殊用途
for item in shoplist:
print item,

我們?cè)趐rint語(yǔ)句的結(jié)尾使用了一個(gè) 逗號(hào) 來(lái)消除每個(gè)print語(yǔ)句自動(dòng)打印的換行符。這樣做有點(diǎn)難看,不過(guò)確實(shí)簡(jiǎn)單有效。

以上這篇詳談python中冒號(hào)與逗號(hào)的區(qū)別就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論