Python:IndexError:元组索引超出范围

use*_*134 6 python python-2.6

在python我有这个代码

if record[0][1]:
Run Code Online (Sandbox Code Playgroud)

问题是..当mysql没有返回任何东西,因此..

record[0][1]
Run Code Online (Sandbox Code Playgroud)

没有数据..

这个python代码失败:

if record[0][1]:
IndexError: tuple index out of range
Run Code Online (Sandbox Code Playgroud)

我只是想让它转到"else"语句,或者只是将这个if语句视为......无效

record[0][1]
Run Code Online (Sandbox Code Playgroud)

没有价值.或数据..(从mysql传入的东西)

cel*_*tas 6

try:
    if record[0][1]:
        # Do stuff
except IndexError:
    pass
Run Code Online (Sandbox Code Playgroud)