--代码--
if __name__ == '__main__': l = [] print(l.__len__() == 0) print(l.__sizeof__() == 40) print(len(l) == 0) print(l == []) print(l == list()) print(l is not True) print(''.join(l) == '') #这个不对,当list中全是空字符串时不适应 print(l.__str__()=='[]')
--执行结果--
C:UserskusyAppDataLocalProgramsPythonPython36python.exe E:/wangjz/PyWorkSpace/LearnPython/checklist.py
True
True
True
True
True
True
True
True
Process finished with exit code 0