新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
詳談python中冒號與逗號的區(qū)別-創(chuàng)新互聯(lián)
注意if\while\for等(或函數(shù)定義)語句在結(jié)尾處包含一個冒號——我們通過它告訴python下面跟著一個語句塊。
--------------冒號的用法
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個數(shù). 2個數(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' ========逗號的特殊用途 for item in shoplist: print item,
本文名稱:詳談python中冒號與逗號的區(qū)別-創(chuàng)新互聯(lián)
瀏覽地址:http://fisionsoft.com.cn/article/esdej.html