wshq 发表于 2015-4-26 10:15:40

Python天天美味(12)

开始以为Python中没有像其他语言一样的条件判断的缩写形式:

return (1==1) ? "is easy" : "my god" //C#中的用法
其实,在Python中,是这样写的:

print (1==2) and 'Fool' or 'Not bad'
输出结果:
  Not bad
  
  Python天天美味系列(总)
  Python    天天美味(10) - 除法小技巧
  Python    天天美味(11) - 可爱的大小写
Python    天天美味(12) - 条件判断的缩写
  Python    天天美味(13) - struct.unpack   
  Python    天天美味(14) - splitlines

  ...
页: [1]
查看完整版本: Python天天美味(12)