Python 中的和!= 区别

今天在编写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,学习笔记)