ok="0"
if status:
ok="1"
Yukarıdaki kodun tek satırlık versiyonu:
ok = "1" if status else "0"
Aralık 20, 2008
python'da tek satırda if else
Kaydol:
Kayıt Yorumları (Atom)
ok="0"
if status:
ok="1"
Yukarıdaki kodun tek satırlık versiyonu:
ok = "1" if status else "0"
1 yorum:
python daha kısa ve anlaşılır ifadeler yazmayı seviyorum. Şöyle olsa daha iyi gibi.
>>> ok = status and 1 or 0
Yorum Gönder