humanL=12my3nameis4katty利用循环语句和判断条件分别输出列表中的字符串和数字。使用Python
代码如下:
L = [1, 2, '', 'my', 3, 'name', 'is', 4, 'katty']
# 输出字符串
for item in L:
if isinstance(item, str) and item != '':
print(item)
# 输出数字
for item in L:
if isinstance(item, int):
print(item)
输出结果如下:
my
name
is
1
2
3
4
原文地址: https://www.cveoy.top/t/topic/fcUS 著作权归作者所有。请勿转载和采集!