我正在使用的API可以返回空[]
列表.
以下条件语句未按预期工作:
if myList is not None: #not working
pass
if myList is not []: #not working
pass
Run Code Online (Sandbox Code Playgroud)
什么会奏效?
ins*_*get 12
我喜欢Zarembisty的回答.虽然,如果你想更明确,你可以随时做:
if len(my_list) == 0:
print "my_list is empty"
Run Code Online (Sandbox Code Playgroud)