Discuss / Python / 宇宙探索编辑部

宇宙探索编辑部

Topic source

晚安

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

>>> L1=['Hello', 'World', 18, 'Apple', None]

>>> L2=[s.upper() for s in L if isinstance(s,str)] 

>>> L2

['HELLO,WORLD', 'APPLE', 'WHAT']

晚安

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

>>> L1=['Hello', 'World', 18, 'Apple', None]

>>> L2=[s.title() for s in L if isinstance(s,str)] 

>>> L2

['Hello,World', 'Apple', 'What']

晚安

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

>>> L1=['Hello', 'World', 18, 'Apple', None]

>>> L2=[s.lower() for s in L if isinstance(s,str)] 

>>> L2

['hello,world', 'apple', 'what']


  • 1

Reply