基本解析
a = [ ]
for i in range(101):
a.append(i)
对应解析:
a = [ i for i in range(101) ]
加 if 的解析
a = [ ]
for i in range(101):
if i % 2 ==1:
a.append(i)
对应解析:
a = [ i for i in range(101) if i %2 ==1]
基本解析
a = [ ]
for i in range(101):
a.append(i)
对应解析:
a = [ i for i in range(101) ]
加 if 的解析
a = [ ]
for i in range(101):
if i % 2 ==1:
a.append(i)
对应解析:
a = [ i for i in range(101) if i %2 ==1]
本文标题:python 列表解析(2019-02-13)
本文链接:https://www.haomeiwen.com/subject/kacdeqtx.html
网友评论