In [54]: User
Out[54]: {0: {'uid': ' rpatil\n'}, 1: {}}
In [55]: User[0]
Out[55]: {'uid': ' rpatil\n'}
In [56]: User[1]
Out[56]: {}
In [57]: if User[1] == '':
....: print 'Null'
....:
In [58]:
So how to check Value is Null in multi dict
I've Tried Following Links but not work None value in python dictionary
In C#, Dictionary is a generic collection which is generally used to store key/value pairs. In Dictionary, the key cannot be null, but value can be.
Check if a Python Dictionary is Empty by Checking Its Lengthif len(empty_dict) == 0: print('This dictionary is empty! ')
Method #1 : Using all() + not operator + values() The combination of above functions can be used to perform this particular task. In this, we check for all the values using all function extracted using values function. The not operator is used to inverse the result to check for any of None value.
To check if a value exists in a dictionary, i.e., if a dictionary has/contains a value, use the in operator and the values() method. Use not in to check if a value does not exist in a dictionary.
Empty dictionaries are falsey. Just use if not dic
.
>>> testDict = {}
>>> if not testDict:
print "Empty"
Empty
So, in your code.
>>> User = {0: {'uid': ' rpatil\n'}, 1: {}}
>>> if not User[1]:
print "NULL"
NULL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With