以下表达式的python等价物是什么?以下表达式的python中的等效内容是什么?
EE_DOUBLE const yplus = (y < 1.0) ? y*u_tau/nu_inf : (2.0-y)*u_tau/nu_inf
欢迎任何建议。许多感谢
以下表达式的python等价物是什么?以下表达式的python中的等效内容是什么?
EE_DOUBLE const yplus = (y < 1.0) ? y*u_tau/nu_inf : (2.0-y)*u_tau/nu_inf
欢迎任何建议。许多感谢
我不太确定C语法了,但我想它会是这样的:
yplus = y*u_tau/nu_inf if (y < 1.0) else (2.0-y)*u_tau/nu_inf
yplus = ((2.0-y)*u_tau/nu_inf, y*u_tau/nu_inf)[y < 1.0]
其他方式
yplus = (y < 1.0) and (y*u_tau/nu_inf) or ((2.0-y)*u_tau/nu_inf)
其他方式
yplus = {True: y*u_tau/nu_inf, False: (2.0-y)*u_tau/nu_inf} [y < 1.0]
其他方式已标记为o thers
yplus = (y*u_tau)/nu_inf if y < 1.0 else (2.0-y)*u_tau/nu_inf
其他方式
if (y < 1.0):
yplus = (y*u_tau)/nu_inf
else:
yplus = (2.0-y)*u_tau/nu_inf
使用Python的三元运算符,因为2.5
yplus = (y*u_tau)/nu_inf if y < 1.0 else (2.0-y)*u_tau/nu_inf
什么是混乱添加?你知道三元运算符是什么吗? –
https://stackoverflow.com/questions/394809/does-python-have-a-ternary-conditional-operator – taras
恐怕我不知道尤金。 – Andrei