我有一个一直在开发的应用程序,但现在我需要将此行转换为 Python。
return (highValue > 21) ? lowValue : highValue;
上面说如果数字highValue大于21,返回lowValue,如果小于21,返回highValue。如何将其转换为 Python?
谢谢!
最佳答案
我相信你正在寻找
>>> highvalue = 25
>>> lowvalue = 21
>>> def myfunc():
... return lowvalue if highvalue>21 else highvalue
...
>>> myfunc()
21
>>>
也可以在这里看看python-ternary-operator .
关于iphone - 将简单的 Obj-C 转换为 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10159930/