Discuss / Python / 11

[s.lower() for s in L1 if not isinstance(s,(int,float))] Traceback (most recent call last): File "<pyshell#176>", line 1, in <module> [s.lower() for s in L1 if not isinstance(s,(int,float))] File "<pyshell#176>", line 1, in <listcomp> [s.lower() for s in L1 if not isinstance(s,(int,float))] AttributeError: 'NoneType' object has no attribute 'lower'

为什么这样不行?

原因不是都说了嘛,None这个类型没有lower()这个方法。


  • 1

Reply