python的三目运算符和not in运算符使用示例
2014-03-03 00:00
881 查看
x = [x for x in range(1,10)] print(x) y =[] result = True if 12 not in x else False # this is the best way print(result) result = True if not 12 in x else False # this way just like as " (not 12) in x" print(result) print(x is y) print(x is not y) # this is the best way print(not x is y) # this way just like as " (not x ) is y" ,so upper is the best way result = 2 if 1 < 2 else 5 if 4 > 5 else 6 # just as 1 > 2 ? 2 : 4 > 5 ? 5 : 6 print(result)
相关文章推荐
- python的三目运算符和not in运算符使用示例
- 在Python中使用成员运算符的示例
- 在Python中使用成员运算符的示例
- 使用python分析git log日志示例
- 使用Python的Bottle框架写一个简单的服务接口的示例
- 忘记ftp密码使用python ftplib库暴力破解密码的方法示例
- python中文分词库结巴使用示例
- 【python】3.6版本使用http.client网络请求示例
- 使用python中的Matplotlib绘图示例
- python使用sqlite示例
- python使用mysqldb连接数据库操作方法示例详解
- Python使用matplotlib绘制正弦和余弦曲线的方法示例
- 使用minidom来处理XML的示例(Python 学习)(转载)
- Python使用time模块实现指定时间触发器示例
- python使用循环实现批量创建文件夹示例
- f2py::演示Fortran二维数组在python中的使用示例
- 使用markdown创作技术博客的示例-以Python完成定时截屏为例
- Pipeline详解及Spark MLlib使用示例(Scala/Java/Python)
- Python使用matplotlib的pie函数绘制饼状图功能示例
- 深入理解Python单元测试unittest的使用示例