当python查询mysql并返回值为null时,cursor.fetchone或fetchall的传参会报一下错误TypeError: bind() takes exactly one argument (2 given)
sqlcmd = "select rowwhichisnull from tableA"
cur.execute(sqlcmd)
rowResult=cur.fetchone()[0]
当if 条件判断sql返回为Null,如果使用了
if rowResult == ‘NULL‘ || rowResult == ‘‘
则就会报开头的TypeError
if判断可设置为:
if rowResult is None:
print("Row Result is None")
else:
print(‘Not None‘)