手机
当前位置:查字典教程网 >脚本专栏 >python >Python 条件判断的缩写方法
Python 条件判断的缩写方法
摘要:return(1==1)?"iseasy":"mygod"//C#中的用法其实,在Python中,是这样写的:print(1==2)and'...

return (1==1) ? "is easy" : "my god" //C#中的用法

其实,在Python中,是这样写的:

print (1==2) and 'Fool' or 'Not bad'

输出结果:

Not bad

【Python 条件判断的缩写方法】相关文章:

python备份文件的脚本

Python 字符串中的字符倒转

python读文件逐行处理的示例代码分享

Python subprocess模块学习总结

python实现网页链接提取的方法分享

在Python中使用异步Socket编程性能测试

Python strip lstrip rstrip使用方法

Python设计模式之代理模式实例

Python去掉字符串中空格的方法

详解Python中的__init__和__new__

精品推荐
分类导航