I wonder what is better to do:
(我想知道做什么更好:)
d = {'a': 1, 'b': 2} 'a' in d True
or:
(要么:)
d = {'a': 1, 'b': 2} d.has_key('a') True
in is definitely more pythonic.
in
(in绝对是pythonic。)
In fact has_key() was removed in Python 3.x .
has_key()
(事实上, 在Python 3.x中删除了has_key() 。)
1.4m articles
1.4m replys
5 comments
57.0k users