练习:请修改列表生成器,通过添加if语句保证列表生成器能正确地执行

#  -*- coding: utf-8 -*-
# L1 = ['Hello', 'World', 18, 'Apple', None]
# ----
# L2 = ???
# ----
# 期待输出: ['hello', 'world', 'apple']
# print(L2)


L1 = ['Hello', 'World', 18, 'Apple', None]
L2 = [x.lower() for x in L1 if isinstance(x, str) == True]
print(L2)
上一篇:通过web自动化实现文件上传


下一篇:pandas之excel操作