Discuss / Python / 看不懂结局

看不懂结局

Topic source

McG后生

#1 Created at ... [Delete] [Delete and Lock User]
L1=['Hello','World',18,'Apple',None]
L2=[s.lower for s in L1 if isinstance(s,str)]
print(L2)

结果 [<built-in method lower of str object at 0x00BD5A00>,

<built-in method lower of str object at 0x00BD5A80>,

<built-in method lower of str object at 0x00C1D280>] 这是什么呀= =

廖雪峰

#2 Created at ... [Delete] [Delete and Lock User]

仔细对照教程的例子:

[s.lower() for s in L]

  • 1

Reply