Discuss / Python / isinstance不必须

isinstance不必须

Topic source
L2 = [s.lower() for s in L1 if type(s) == type('')]
L3 = [s.lower() if type(s) == type('') else s for s in L1]

按之前学过的 type() 即可完成判断, 这是我在看到 isinstance 这么长英文单词麻掉之前的反应


  • 1

Reply