Python條件判斷的縮寫方法
來源:懂視網
責編:小采
時間:2020-11-27 14:29:24
Python條件判斷的縮寫方法
Python條件判斷的縮寫方法:return (1==1) is easy : my god //C#中的用法 其實,在Python中,是這樣寫的: print (1==2) and 'Fool' or 'Not bad' 輸出結果: Not bad
導讀Python條件判斷的縮寫方法:return (1==1) is easy : my god //C#中的用法 其實,在Python中,是這樣寫的: print (1==2) and 'Fool' or 'Not bad' 輸出結果: Not bad

return (1==1) ? "is easy" : "my god" //C#中的用法
其實,在Python中,是這樣寫的:
print (1==2) and 'Fool' or 'Not bad'
輸出結果:
Not bad
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
Python條件判斷的縮寫方法
Python條件判斷的縮寫方法:return (1==1) is easy : my god //C#中的用法 其實,在Python中,是這樣寫的: print (1==2) and 'Fool' or 'Not bad' 輸出結果: Not bad