2
我做一个脚本,我得到一些值从数据库中,但有时这个值可以是无,但是当我把它分配给一个变量,并尝试比较它,我得到这个错误:在Python无类型问题2.6
TypeError: 'NoneType' object is unsubscriptable
我已经尝试过这样的:
if sgSlate[ 'sg_client_2' ][ 'name' ] != None:
self.ui.brandComboBox_2.setEditText(sgSlate[ 'sg_client_2' ]['name' ])
if not isinstanceof(sgSlate[ 'sg_client_2' ][ 'name' ], None) != "":
self.ui.brandComboBox_2.setEditText(sgSlate[ 'sg_client_2' ]['name' ])
if sgSlate[ 'sg_client_2' ][ 'name' ] is not None:
self.ui.brandComboBox_2.setEditText(sgSlate[ 'sg_client_2' ]['name' ])
if type(sgSlate[ 'sg_client_2' ][ 'name' ]) is not type(None):
self.ui.brandComboBox_2.setEditText(sgSlate[ 'sg_client_2' ]['name' ])
,并没有一次成功。
预先感谢您。
比你非常努力 – Vordok 2011-04-02 01:39:06
好的,就是这样。直到4月2日在所有时区都没有更多的投票,我厌倦了这些愚蠢的独角兽:) – 2011-04-02 02:18:32