【发布时间】:2010-11-22 02:19:59
【问题描述】:
我有这个
bc = 'off'
if c.page == 'blog':
bc = 'on'
print(bc)
有没有更 Pythonic(和/或更短)的方式在 Python 中编写?
【问题讨论】:
-
你有使用'on'和'off'吗?是否可以仅用布尔值来表示此信息,我的意思是 bc = (c.page == 'blog') 要好得多。
标签: python if-statement