Python条件判断的缩写方法
来源:动视网
责编:小采
时间:2020-11-27 14:29:24
Python条件判断的缩写方法
Python条件判断的缩写方法:return (1==1) is easy : my god //C#中的用法 其实,在Python中,是这样写的: print (1==2) and 'Fool' or 'Not bad' 输出结果: Not bad
导读Python条件判断的缩写方法:return (1==1) is easy : my god //C#中的用法 其实,在Python中,是这样写的: print (1==2) and 'Fool' or 'Not bad' 输出结果: Not bad

return (1==1) ? "is easy" : "my god" //C#中的用法
其实,在Python中,是这样写的:
print (1==2) and 'Fool' or 'Not bad'
输出结果:
Not bad
Python条件判断的缩写方法
Python条件判断的缩写方法:return (1==1) is easy : my god //C#中的用法 其实,在Python中,是这样写的: print (1==2) and 'Fool' or 'Not bad' 输出结果: Not bad