这些不是无测试.
if val != None:
if not (val is None):
if val is not None:
Run Code Online (Sandbox Code Playgroud)
哪个更好,为什么?
我有一个包含空列表的列表:
list1 = [[], [], [], [], [], 'text', 'text2', [], 'moreText']
Run Code Online (Sandbox Code Playgroud)
如何删除空列表以便我得到:
list2 = ['text', 'text2', 'moreText']
Run Code Online (Sandbox Code Playgroud)
我尝试了list.remove(''),但这不起作用.