【发布时间】:2012-11-27 17:31:55
【问题描述】:
我有这个我写的小sn-p python 代码。它有效,但我认为应该有一种更简化的方法来实现相同的结果。我只是没看到。有什么想法吗?
if tx_avt >= 100: tx = 1
elif tx_avt < 100 and tx_avt >= 50: tx = 2
elif tx_avt < 50 and tx_avt >= 25: tx = 3
elif tx_avt < 25 and tx_avt >= 12.5: tx = 4
else: tx = 5
【问题讨论】:
-
如果你把作业放在他们自己的行上适当缩进,这会更易读。
标签: python if-statement