Python 中的<>和!= 区别

小虾米 阅读:805 2021-03-31 21:16:58 评论:0

今天在编写Python MySQL 采集脚本过程中,需要使用到“不等于”表达方式。

第一种写法:   在Python2.6以前版本:“不等于”  

if (string.atof(func.get_item(mysql_status, 'Qcache_hits')) + string.atof( 
      func.get_item(mysql_status, 'Com_select'))) <> 0:
 
第二种写法:在Python3.0以后版本:“不等于”
if (string.atof(func.get_item(mysql_status, 'Qcache_hits')) + string.atof( 
      func.get_item(mysql_status, 'Com_select'))) != 0:

标签:Python
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号